userver: userver/server/handlers/dns_client_control.hpp Source File
⚠️ This is the documentation for an old userver version. Click here to switch to the latest version.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
dns_client_control.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/server/handlers/dns_client_control.hpp
4/// @brief @copybrief server::handlers::DnsClientControl
5
6#include <userver/server/handlers/http_handler_base.hpp>
7
8USERVER_NAMESPACE_BEGIN
9
10namespace clients::dns {
11class Resolver;
12} // namespace clients::dns
13
14namespace server::handlers {
15
16// clang-format off
17
18/// @ingroup userver_components userver_http_handlers
19///
20/// @brief Handlers that controls the DNS client.
21///
22/// The component has no service configuration except the
23/// @ref userver_http_handlers "common handler options".
24///
25/// ## Static configuration example:
26///
27/// @snippet components/common_server_component_list_test.cpp Sample handler dns client control component config
28///
29/// ## Schema
30/// Set an URL path argument `command` to one of the following values:
31/// * `reload_hosts` - to reload hosts file cache
32/// * `flush_cache` - to remove network cache records for `name` specified as a query parameter
33/// * `flush_cache_full` - to completely wipe network cache
34
35// clang-format on
36
37class DnsClientControl final : public HttpHandlerBase {
38 public:
39 /// @ingroup userver_component_names
40 /// @brief The default name of server::handlers::DnsClientControl
41 static constexpr std::string_view kName = "handler-dns-client-control";
42
43 DnsClientControl(const components::ComponentConfig&,
44 const components::ComponentContext&);
45
46 std::string HandleRequestThrow(const http::HttpRequest&,
47 request::RequestContext&) const override;
48
49 static yaml_config::Schema GetStaticConfigSchema();
50
51 private:
52 clients::dns::Resolver* resolver_;
53};
54
55} // namespace server::handlers
56
57template <>
58inline constexpr bool
59 components::kHasValidate<server::handlers::DnsClientControl> = true;
60
61USERVER_NAMESPACE_END