userver: userver/server/handlers/handler_config.hpp Source File
Loading...
Searching...
No Matches
handler_config.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/server/handlers/handler_config.hpp
4/// @brief HTTP handler static configuration
5
6#include <optional>
7#include <string>
8#include <variant>
9#include <vector>
10
11#include <userver/server/handlers/auth/handler_auth_config.hpp>
12#include <userver/server/handlers/fallback_handlers.hpp>
13#include <userver/server/http/http_status.hpp>
14#include <userver/server/request/request_config.hpp>
15#include <userver/utils/overloaded.hpp>
16
17USERVER_NAMESPACE_BEGIN
18
19namespace server {
20struct ServerConfig;
21} // namespace server
22
23namespace server::handlers {
24
25/// Defines matching behavior for paths with trailing slashes.
27 kBoth, ///< ignore trailing slashes when matching paths
28 kStrictMatch, ///< require exact match for trailing slashes in paths
29
30 kDefault = kBoth,
31};
32
34 /// Either a path pattern of the handler that may contain path-argument placeholders, or a fallback handler
35 std::variant<std::string, FallbackHandler> path;
36 std::optional<std::string> task_processor;
37 std::string method;
38 request::HttpRequestConfig request_config{};
39 size_t request_body_size_log_limit{0};
40 size_t request_headers_size_log_limit{0};
41 size_t response_data_size_log_limit{0};
42 std::optional<auth::HandlerAuthConfig> auth;
43 UrlTrailingSlashOption url_trailing_slash{UrlTrailingSlashOption::kDefault};
44 std::optional<size_t> max_requests_in_flight;
45 std::optional<size_t> max_requests_per_second;
46 bool decompress_request{true};
47 bool throttling_enabled{true};
48 bool response_body_stream{false};
49 std::optional<bool> set_response_server_hostname;
50 bool set_tracing_headers{true};
51 bool deadline_propagation_enabled{true};
52 bool deadline_propagation_prefer_timestamp{false};
53 bool enable_write_statistics{true};
54 http::HttpStatus deadline_expired_status_code{498};
55
56 const std::string& GetLowCardinalityRequestPath() const;
57};
58
59HandlerConfig ParseHandlerConfigsWithDefaults(
60 const yaml_config::YamlConfig& value,
61 const server::ServerConfig& server_config,
62 bool is_monitor = false
63);
64
65} // namespace server::handlers
66
67USERVER_NAMESPACE_END