userver: userver/server/request/json_data.hpp Source File
Loading...
Searching...
No Matches
json_data.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/server/request/json_data.hpp
4/// @brief Functions that handle JSON requests and responses stored in context.
5
6#include <userver/formats/json/value.hpp>
7#include <userver/server/request/request_context.hpp>
8
9USERVER_NAMESPACE_BEGIN
10
11namespace server::request {
12
13/// @returns A pointer to json request if it was parsed successfully and stored in the context or
14/// nullptr otherwise.
15const formats::json::Value* GetRequestJson(const RequestContext& context);
16
17/// @brief Saves a parsed json request to the context.
18/// @returns A reference to the saved json.
19formats::json::Value& SetRequestJson(RequestContext& context, formats::json::Value request_json);
20
21/// @returns A pointer to json response if it was produced successfully and stored in the context
22/// or nullptr otherwise.
23const formats::json::Value* GetResponseJson(const RequestContext& context);
24
25/// @brief Saves a json response to the context.
26/// @returns A reference to the saved json.
27formats::json::Value& SetResponseJson(RequestContext& context, formats::json::Value request_json);
28
29} // namespace server::request
30
31USERVER_NAMESPACE_END