userver: userver/server/handlers/handler_config.hpp Source File
Loading...
Searching...
No Matches
handler_config.hpp
1#pragma once
2
3#include <optional>
4#include <string>
5#include <variant>
6#include <vector>
7
8#include <userver/server/handlers/auth/handler_auth_config.hpp>
9#include <userver/server/handlers/fallback_handlers.hpp>
10#include <userver/server/http/http_status.hpp>
11#include <userver/server/request/request_config.hpp>
12
13USERVER_NAMESPACE_BEGIN
14
15namespace server {
16struct ServerConfig;
17} // namespace server
18
19namespace server::handlers {
20
21/// Defines matching behavior for paths with trailing slashes.
22enum class UrlTrailingSlashOption {
23 kBoth, ///< ignore trailing slashes when matching paths
24 kStrictMatch, ///< require exact match for trailing slashes in paths
25
26 kDefault = kBoth,
27};
28
29struct HandlerConfig {
30 std::variant<std::string, FallbackHandler> path;
31 std::string task_processor;
32 std::string method;
33 request::HttpRequestConfig request_config{};
34 size_t request_body_size_log_limit{0};
35 size_t request_headers_size_log_limit{0};
36 size_t response_data_size_log_limit{0};
37 std::optional<auth::HandlerAuthConfig> auth;
38 UrlTrailingSlashOption url_trailing_slash{UrlTrailingSlashOption::kDefault};
39 std::optional<size_t> max_requests_in_flight;
40 std::optional<size_t> max_requests_per_second;
41 bool decompress_request{true};
42 bool throttling_enabled{true};
43 bool response_body_stream{false};
44 std::optional<bool> set_response_server_hostname;
45 bool set_tracing_headers{true};
46 bool deadline_propagation_enabled{true};
47 http::HttpStatus deadline_expired_status_code{498};
48};
49
50HandlerConfig ParseHandlerConfigsWithDefaults(
51 const yaml_config::YamlConfig& value,
52 const server::ServerConfig& server_config,
53 bool is_monitor = false
54);
55
56} // namespace server::handlers
57
58USERVER_NAMESPACE_END