2019-02-25 14:48:22 +01:00
|
|
|
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
|
2015-07-21 16:10:13 +02:00
|
|
|
|
|
|
|
#ifndef HTTPUTILITY_H
|
|
|
|
#define HTTPUTILITY_H
|
|
|
|
|
2019-02-14 17:27:17 +01:00
|
|
|
#include "remote/url.hpp"
|
2015-07-21 16:10:13 +02:00
|
|
|
#include "base/dictionary.hpp"
|
2019-02-14 13:12:36 +01:00
|
|
|
#include <boost/beast/http.hpp>
|
2019-05-23 15:25:08 +02:00
|
|
|
#include <string>
|
2015-07-21 16:10:13 +02:00
|
|
|
|
|
|
|
namespace icinga
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper functions.
|
|
|
|
*
|
|
|
|
* @ingroup remote
|
|
|
|
*/
|
2017-12-31 07:22:16 +01:00
|
|
|
class HttpUtility
|
2015-07-21 16:10:13 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
2019-02-14 17:27:17 +01:00
|
|
|
static Dictionary::Ptr FetchRequestParameters(const Url::Ptr& url, const std::string& body);
|
2015-07-30 17:50:17 +02:00
|
|
|
static Value GetLastParameter(const Dictionary::Ptr& params, const String& key);
|
2019-05-23 15:25:08 +02:00
|
|
|
|
|
|
|
static void SendJsonBody(boost::beast::http::response<boost::beast::http::string_body>& response, const Dictionary::Ptr& params, const Value& val);
|
2019-02-14 16:07:06 +01:00
|
|
|
static void SendJsonError(boost::beast::http::response<boost::beast::http::string_body>& response, const Dictionary::Ptr& params, const int code,
|
|
|
|
const String& verbose = String(), const String& diagnosticInformation = String());
|
2015-07-21 16:10:13 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* HTTPUTILITY_H */
|