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