1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */ 2 3 #ifndef HTTPUTILITY_H 4 #define HTTPUTILITY_H 5 6 #include "remote/url.hpp" 7 #include "base/dictionary.hpp" 8 #include <boost/beast/http.hpp> 9 #include <string> 10 11 namespace icinga 12 { 13 14 /** 15 * Helper functions. 16 * 17 * @ingroup remote 18 */ 19 class HttpUtility 20 { 21 22 public: 23 static Dictionary::Ptr FetchRequestParameters(const Url::Ptr& url, const std::string& body); 24 static Value GetLastParameter(const Dictionary::Ptr& params, const String& key); 25 26 static void SendJsonBody(boost::beast::http::response<boost::beast::http::string_body>& response, const Dictionary::Ptr& params, const Value& val); 27 static void SendJsonError(boost::beast::http::response<boost::beast::http::string_body>& response, const Dictionary::Ptr& params, const int code, 28 const String& verbose = String(), const String& diagnosticInformation = String()); 29 }; 30 31 } 32 33 #endif /* HTTPUTILITY_H */ 34