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