userver: userver/components/headers_propagator_component.hpp Source File
Loading...
Searching...
No Matches
headers_propagator_component.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/components/headers_propagator_component.hpp
4/// @brief HeadersPropagatorComponent and default components
5
6#include <memory>
7
8#include <userver/components/loggable_component_base.hpp>
9
10USERVER_NAMESPACE_BEGIN
11
12namespace server::http {
13class HeadersPropagator;
14} // namespace server::http
15
16namespace components {
17
18// clang-format on
19
20/// @ingroup userver_components
21///
22/// @brief Headers Propagator Component can scrape configured headers
23/// and then enrich HttpClient request with them.
24///
25/// The component can be configured in service config.
26///
27/// ## Static options:
28/// Name | Description | Default value
29/// ---- | ----------- | -------------
30/// headers | List of headers to propagate | []
31///
32// clang-format on
33class HeadersPropagatorComponent final
35 public:
36 /// @ingroup userver_component_names
37 /// @brief The default name of components::HeadersPropagatorComponent
38 /// component
39 static constexpr std::string_view kName = "headers-propagator";
40
41 HeadersPropagatorComponent(const components::ComponentConfig&,
42 const components::ComponentContext&);
43 ~HeadersPropagatorComponent() override;
44
45 static yaml_config::Schema GetStaticConfigSchema();
46
47 server::http::HeadersPropagator& Get();
48
49 private:
50 std::unique_ptr<server::http::HeadersPropagator> propagator_;
51};
52
53} // namespace components
54
55template <>
56inline constexpr bool
57 components::kHasValidate<components::HeadersPropagatorComponent> = true;
58
59template <>
60inline constexpr auto
61 components::kConfigFileMode<components::HeadersPropagatorComponent> =
63
64USERVER_NAMESPACE_END