Github   Telegram
Loading...
Searching...
No Matches
ping.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/server/handlers/ping.hpp
4/// @brief @copybrief server::handlers::Ping
5
6#include <userver/server/handlers/http_handler_base.hpp>
7
8USERVER_NAMESPACE_BEGIN
9
10namespace server::handlers {
11
12/// @ingroup userver_components userver_http_handlers
13///
14/// @brief Handler that returns HTTP 200 if the service is OK and able to
15/// process requests.
16///
17/// Uses components::ComponentContext::IsAnyComponentInFatalState() to detect
18/// fatal state (can not process requests).
19///
20/// The component has no service configuration except the
21/// @ref userver_http_handlers "common handler options".
22class Ping final : public HttpHandlerBase {
23 public:
24 Ping(const components::ComponentConfig& config,
25 const components::ComponentContext& component_context);
26
27 /// @ingroup userver_component_names
28 /// @brief The default name of server::handlers::Ping
29 static constexpr std::string_view kName = "handler-ping";
30
31 std::string HandleRequestThrow(
32 const http::HttpRequest& request,
33 request::RequestContext& context) const override;
34
35 static yaml_config::Schema GetStaticConfigSchema();
36
37 private:
38 const components::ComponentContext& components_;
39};
40
41} // namespace server::handlers
42
43template <>
44inline constexpr bool components::kHasValidate<server::handlers::Ping> = true;
45
46USERVER_NAMESPACE_END