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 response_data_size_log_limit{0};
36 std::optional<auth::HandlerAuthConfig> auth;
37 UrlTrailingSlashOption url_trailing_slash{UrlTrailingSlashOption::kDefault};
38 std::optional<size_t> max_requests_in_flight;
39 std::optional<size_t> max_requests_per_second;
40 bool decompress_request{true};
41 bool throttling_enabled{true};
42 bool response_body_stream{false};
43 std::optional<bool> set_response_server_hostname;
44 bool set_tracing_headers{true};
45 bool deadline_propagation_enabled{true};
46 http::HttpStatus deadline_expired_status_code{498};
47};
48
49HandlerConfig ParseHandlerConfigsWithDefaults(
50 const yaml_config::YamlConfig& value,
51 const server::ServerConfig& server_config, bool is_monitor = false);
52
53} // namespace server::handlers
54
55USERVER_NAMESPACE_END