MCPcopy Create free account
hub / github.com/Icinga/icinga2 / SendJsonBody

Method SendJsonBody

lib/remote/httputility.cpp:69–76  ·  view source on GitHub ↗

* Stream a JSON-encoded body to the client. * * This function sets the Content-Type header to "application/json", starts the streaming of the response, * and encodes the given value as JSON to the client. If pretty-print is requested, the JSON output will be * formatted accordingly. It is assumed that the response status code and other necessary headers have already * been set. * * @param r

Source from the content-addressed store, hash-verified

67 * @param yc The yield context to use for asynchronous operations.
68 */
69void HttpUtility::SendJsonBody(HttpApiResponse& response, const Dictionary::Ptr& params, const Value& val, boost::asio::yield_context& yc)
70{
71 namespace http = boost::beast::http;
72
73 response.set(http::field::content_type, "application/json");
74 response.StartStreaming(false);
75 response.GetJsonEncoder(params && GetLastParameter(params, "pretty")).Encode(val, &yc);
76}
77
78void HttpUtility::SendJsonBody(HttpApiResponse& response, const Dictionary::Ptr& params, const Value& val)
79{

Callers

nothing calls this directly

Calls 3

StartStreamingMethod · 0.80
GetJsonEncoderMethod · 0.80
EncodeMethod · 0.45

Tested by

no test coverage detected