userver: userver/clients/http/client_with_plugins.hpp Source File
Loading...
Searching...
No Matches
client_with_plugins.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/clients/http/client_with_plugins.hpp
4/// @brief @copybrief clients::http::ClientWithPlugins
5
6#ifdef USERVER_TVM2_HTTP_CLIENT
7#error Use clients::Http from clients/http.hpp instead
8#endif
9
10#include <userver/clients/http/client.hpp>
11#include <userver/clients/http/plugin.hpp>
12#include <userver/utils/impl/internal_tag.hpp>
13#include <userver/utils/impl/wait_token_storage.hpp>
14
15USERVER_NAMESPACE_BEGIN
16
17namespace clients::http {
18
19class ClientCore;
20
21/// @ingroup userver_clients
22///
23/// @brief HTTP client that returns a HTTP request builder from
24/// CreateRequest() with applied plugins.
25///
26/// Usually retrieved from @ref components::HttpClient component.
27/// Can also be created manually using @ref clients::http::Client::CreateHttpClient()
28class ClientWithPlugins final : public Client {
29public:
30 /// @cond
31 // For internal use only
32 ClientWithPlugins(
33 utils::impl::InternalTag,
34 std::shared_ptr<ClientCore> client_core,
35 std::vector<utils::NotNull<clients::http::Plugin*>> plugins
36 );
37 /// @endcond
38
39 ~ClientWithPlugins() override;
40
41 /// @brief Returns a HTTP request builder type with preset values of
42 /// User-Agent, plugins and some of the Testsuite stuff (if any).
43 ///
44 /// @note This method is thread-safe despite being non-const.
45 Request CreateRequest() override;
46
47private:
48 std::shared_ptr<ClientCore> client_core_;
49 std::vector<utils::NotNull<clients::http::Plugin*>> plugins_;
50 utils::impl::WaitTokenStorage wts_;
51};
52
53} // namespace clients::http
54
55USERVER_NAMESPACE_END