userver
C++ Async Framework
Documentation
API Groups
Namespaces
Reference
Class List
Class Index
File List
Macros
All
e
i
l
r
t
u
Functions
Macros
e
i
l
r
t
u
Examples
Toggle main menu visibility
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
Concepts
Loading...
Searching...
No Matches
All results
plugin.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/clients/http/plugin.hpp
4
/// @brief @copybrief clients::http::Plugin
5
6
#
include
<
chrono
>
7
#
include
<
string
>
8
#
include
<
vector
>
9
10
#
include
<
userver
/
utils
/
not_null
.
hpp
>
11
12
USERVER_NAMESPACE_BEGIN
13
14
namespace
tracing
{
15
class
Span;
16
}
17
18
namespace
clients::http {
19
20
class
RequestState;
21
class
Response;
22
23
/// @brief Auxiliary entity that allows editing request to a client
24
/// from plugins
25
class
PluginRequest
final
{
26
public
:
27
/// @cond
28
explicit
PluginRequest(RequestState& state);
29
/// @endcond
30
31
void
SetHeader(std::string_view name, std::string_view value);
32
33
void
AddQueryParams(std::string_view params);
34
35
void
SetTimeout(std::chrono::milliseconds ms);
36
37
private
:
38
RequestState& state_;
39
};
25
class
PluginRequest
final
{
…
};
40
41
/// @brief Base class for HTTP Client plugins
42
class
Plugin
{
43
public
:
44
explicit
Plugin(std::string name);
45
46
virtual
~Plugin() =
default
;
47
48
/// @brief Get plugin name
49
const
std::string&
GetName
()
const
;
50
51
/// @brief The hook is called just after the "external" Span is created.
52
/// You might want to add custom tags from the hook.
53
/// The hook is called only once before any network interaction and is NOT called before each retry.
54
/// The hook is executed in the context of the parent task which created the request.
55
virtual
void
HookCreateSpan
(PluginRequest& request,
tracing
::Span& span) = 0;
56
57
/// @brief The hook is called before actual HTTP request sending and before
58
/// DNS name resolution.
59
/// This hook is called on each retry.
60
///
61
/// @warning The hook is called in libev thread, not in coroutine context! Do
62
/// not do any heavy work here, offload it to other hooks.
63
virtual
void
HookPerformRequest
(PluginRequest& request) = 0;
64
65
/// @brief The hook is called after the HTTP response is received or the
66
/// timeout is passed.
67
///
68
/// @warning The hook is called in libev thread, not in coroutine context! Do
69
/// not do any heavy work here, offload it to other hooks.
70
virtual
void
HookOnCompleted
(PluginRequest& request, Response& response) = 0;
71
72
private
:
73
const
std::string name_;
74
};
42
class
Plugin
{
…
};
75
76
namespace
impl {
77
78
class
PluginPipeline
final
{
79
public
:
80
PluginPipeline(
const
std::vector<
utils
::
NotNull
<
Plugin
*>>& plugins);
81
82
void
HookPerformRequest(RequestState& request);
83
84
void
HookCreateSpan(RequestState& request,
tracing
::Span& span);
85
86
void
HookOnCompleted(RequestState& request, Response& response);
87
88
private
:
89
const
std::vector<
utils
::
NotNull
<
Plugin
*>> plugins_;
90
};
91
92
}
// namespace impl
93
94
}
// namespace clients::http
95
96
USERVER_NAMESPACE_END
Docs version:
v1.0
,
v2.0
,
trunk/develop
userver
clients
http
plugin.hpp
Generated on Wed Apr 30 2025 15:48:43 for userver by
Doxygen
1.13.2