userver: userver/clients/http/client_with_middlewares.hpp Source File
Loading...
Searching...
No Matches
client_with_middlewares.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/clients/http/client_with_middlewares.hpp
4/// @brief @copybrief clients::http::ClientWithMiddlewares
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/middlewares/base.hpp>
12#include <userver/utils/impl/internal_tag_fwd.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 middlewares.
25///
26/// Usually retrieved from @ref components::HttpClient component.
27/// Can also be created manually using @ref clients::http::Client::CreateHttpClient()
28class ClientWithMiddlewares final : public Client {
29public:
30 /// @cond
31 // For internal use only
32 ClientWithMiddlewares(
33 utils::impl::InternalTag,
34 std::shared_ptr<ClientCore> client_core,
35 std::vector<utils::NotNull<clients::http::MiddlewareBase*>> middlewares
36 );
37 /// @endcond
38
39 ~ClientWithMiddlewares() override;
40
41 /// @brief Returns a HTTP request builder type with preset values of
42 /// User-Agent, middlewares 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
47 /// @cond
48 // For internal use only.
49 std::size_t GetActiveRequestCountDebug() const;
50 /// @endcond
51
52private:
53 std::shared_ptr<ClientCore> client_core_;
54 std::vector<utils::NotNull<clients::http::MiddlewareBase*>> middlewares_;
55 utils::impl::WaitTokenStorage wts_;
56};
57
58} // namespace clients::http
59
60USERVER_NAMESPACE_END