userver: userver/server/handlers/dns_client_control.hpp Source File
Loading...
Searching...
No Matches
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/// @ingroup userver_components userver_http_handlers
17///
18/// @brief Handlers that controls the DNS client.
19///
20/// The component has no service configuration except the
21/// @ref userver_http_handlers "common handler options".
22///
23/// ## Static configuration example:
24///
25/// @snippet components/common_server_component_list_test.cpp Sample handler dns client control component config
26///
27/// ## Schema
28/// Set an URL path argument `command` to one of the following values:
29/// * `reload_hosts` - to reload hosts file cache
30/// * `flush_cache` - to remove network cache records for `name` specified as a query parameter
31/// * `flush_cache_full` - to completely wipe network cache
32class DnsClientControl final : public HttpHandlerBase {
33public:
34 /// @ingroup userver_component_names
35 /// @brief The default name of server::handlers::DnsClientControl
36 static constexpr std::string_view kName = "handler-dns-client-control";
37
38 DnsClientControl(const components::ComponentConfig&, const components::ComponentContext&);
39
40 std::string HandleRequestThrow(const http::HttpRequest&, request::RequestContext&) const override;
41
42 static yaml_config::Schema GetStaticConfigSchema();
43
44private:
45 clients::dns::Resolver* resolver_;
46};
47
48} // namespace server::handlers
49
50template <>
51inline constexpr bool components::kHasValidate<server::handlers::DnsClientControl> = true;
52
53USERVER_NAMESPACE_END