userver: userver/server/request/task_inherited_request.hpp Source File
Loading...
Searching...
No Matches
task_inherited_request.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/server/request/task_inherited_request.hpp
4/// @brief Functions that provide access to HttpRequest stored in
5/// TaskInheritedVariable.
6
7#include <string>
8#include <string_view>
9
10#include <boost/container/small_vector.hpp>
11#include <boost/range/iterator_range.hpp>
12
13#include <userver/http/header_map.hpp>
14
15USERVER_NAMESPACE_BEGIN
16
17namespace http::headers {
18class PredefinedHeader;
19} // namespace http::headers
20
21namespace server::request {
22
23struct Header {
24 std::string_view name;
25 std::string value;
26
27 Header(std::string_view name, std::string value) : name(name), value(std::move(value)) {}
28};
29
31
32/// @brief Get a header from server::http::HttpRequest that is handled by the
33/// current task hierarchy.
34/// @return Header value or an empty string, if none such
35const std::string& GetPropagatedHeader(std::string_view header_name);
36
37/// @overload
38const std::string& GetPropagatedHeader(const USERVER_NAMESPACE::http::headers::PredefinedHeader& header_name);
39
40/// @brief Checks whether specified header exists in server::http::HttpRequest
41/// that is handled by the current task hierarchy.
42/// @return `true` if the header exists, `false` otherwise
43bool HasPropagatedHeader(std::string_view header_name);
44
45/// @overload
46bool HasPropagatedHeader(const USERVER_NAMESPACE::http::headers::PredefinedHeader& header_name);
47
48/// @brief Get a headers that is handled by the current task hierarchy.
50
51/// @brief Set a headers that is handled by the current task hierarchy.
52void SetPropagatedHeaders(HeadersToPropagate headers);
53
54/// @brief Get a query parameter from server::http::HttpRequest that is handled
55/// by the current task hierarchy.
56/// @return Parameter value or an empty string, if none such
57const std::string& GetTaskInheritedQueryParameter(std::string_view name);
58
59/// @brief Checks whether specified query parameter exists in
60/// server::http::HttpRequest that is handled by the current task hierarchy.
61/// @return `true` if the parameter exists, `false` otherwise
62bool HasTaskInheritedQueryParameter(std::string_view name);
63
64} // namespace server::request
65
66USERVER_NAMESPACE_END