userver: server::handlers::HandlerBase Class Reference
Loading...
Searching...
No Matches
server::handlers::HandlerBase Class Referenceabstract

#include <userver/server/handlers/handler_base.hpp>

Detailed Description

Base class for the request handlers.

Each handler has an associated path and invoked only for the requests for that path.

Static options:

Name Description Default value
path if a request matches this path wildcard then process it by handler -
as_fallback set to "implicit-http-options" and do not specify a path if this handler processes the OPTIONS requests for paths that do not process OPTIONS method -
task_processor a task processor to execute the requests -
method comma-separated list of allowed HTTP methods. HEAD method is implicitly enabled if GET method is enabled -
max_request_size max size of the whole request 1024 * 1024
max_headers_size max request headers size 65536
parse_args_from_body optional field to parse request according to x-www-form-urlencoded rules and make parameters accessible as query parameters false
auth server::handlers::auth::HandlerAuthConfig authorization config -
url_trailing_slash 'both' to treat URLs with and without a trailing slash as equal, 'strict-match' otherwise 'both'
max_requests_in_flight integer to limit max pending requests to this handler <no limit>
request_body_size_log_limit trim request to this size before logging 512
response_data_size_log_limit trim responses to this size before logging 512
max_requests_per_second integer to limit RPS to this handler <no limit>
decompress_request allow decompression of the requests true
throttling_enabled allow throttling of the requests by components::Server , for more info see its max_response_size_in_flight and requests_queue_size_threshold options true
set-response-server-hostname set to true to add the X-YaTaxi-Server-Hostname header with instance name, set to false to not add the header <takes the value from components::Server config>
monitor-handler Overrides the in-code is_monitor flag that makes the handler run either on server.listener or on server.listener-monitor
set_tracing_headers whether to set http tracing headers (X-YaTraceId, X-YaSpanId, X-RequestId) true
deadline_propagation_enabled when false, disables HTTP handler deadline propagation true
deadline_expired_status_code the HTTP status code to return if the request deadline expires 498

Definition at line 48 of file handler_base.hpp.

+ Inheritance diagram for server::handlers::HandlerBase:

Public Member Functions

 HandlerBase (const components::ComponentConfig &config, const components::ComponentContext &component_context, bool is_monitor=false)
 
virtual void HandleRequest (request::RequestBase &request, request::RequestContext &context) const =0
 
virtual void ReportMalformedRequest (request::RequestBase &) const
 
bool IsMonitor () const
 Returns whether this is a monitoring handler.
 
const HandlerConfigGetConfig () const
 Returns handler config.
 
ComponentHealth GetComponentHealth () const override
 
void OnLoadingCancelled () override
 
void OnAllComponentsLoaded () override
 
void OnAllComponentsAreStopping () override
 

Static Public Member Functions

static yaml_config::Schema GetStaticConfigSchema ()
 

Protected Types

using HandlerErrorCode = handlers::HandlerErrorCode
 
using InternalMessage = handlers::InternalMessage
 
using ExternalBody = handlers::ExternalBody
 
using ClientError = handlers::ClientError
 
using InternalServerError = handlers::InternalServerError
 
using LoggableComponentBase = ComponentBase
 Legacy alias, use ComponentBase instead.
 

Member Typedef Documentation

◆ ClientError

◆ ExternalBody

◆ HandlerErrorCode

◆ InternalMessage

◆ InternalServerError

◆ LoggableComponentBase

using components::ComponentBase::LoggableComponentBase = ComponentBase
protectedinherited

Legacy alias, use ComponentBase instead.

Definition at line 69 of file component_base.hpp.

Member Function Documentation

◆ GetComponentHealth()

ComponentHealth components::ComponentBase::GetComponentHealth ( ) const
inlineoverridevirtualinherited

Override this function to inform the world of the state of your component.

Warning
The function is called concurrently from multiple threads.

Reimplemented from components::RawComponentBase.

Definition at line 35 of file component_base.hpp.

◆ HandleRequest()

virtual void server::handlers::HandlerBase::HandleRequest ( request::RequestBase & request,
request::RequestContext & context ) const
pure virtual

Parses request, executes processing routines, and fills response accordingly. Does not throw.

Implemented in server::handlers::HttpHandlerBase.

◆ IsMonitor()

bool server::handlers::HandlerBase::IsMonitor ( ) const
inline

Returns whether this is a monitoring handler.

Definition at line 65 of file handler_base.hpp.

◆ OnAllComponentsAreStopping()

void components::ComponentBase::OnAllComponentsAreStopping ( )
inlineoverridevirtualinherited

Component may use this function to stop doing work before the stop of the components that depend on it.

Base components may override it and make final to do some work before the derived object constructor is called. Don't use it otherwise.

Reimplemented from components::RawComponentBase.

Reimplemented in urabbitmq::ConsumerComponentBase, and components::Server.

Definition at line 60 of file component_base.hpp.

◆ OnAllComponentsLoaded()

void components::ComponentBase::OnAllComponentsLoaded ( )
inlineoverridevirtualinherited

Component may use this function to finalize registration of other components that depend on it (for example, handler components register in server component, and the latter uses OnAllComponentsLoaded() to start processing requests).

Base components may override it and make final to do some work after the derived object constructor is called. Don't use it otherwise.

Reimplemented from components::RawComponentBase.

Reimplemented in urabbitmq::ConsumerComponentBase, components::Server, and server::handlers::Ping.

Definition at line 53 of file component_base.hpp.

◆ OnLoadingCancelled()

void components::ComponentBase::OnLoadingCancelled ( )
inlineoverridevirtualinherited

Called once if the creation of any other component failed. If the current component expects some other component to take any action with the current component, this call is a signal that such action may never happen due to components loading was cancelled. Application components might not want to override it.

Reimplemented from components::RawComponentBase.

Definition at line 44 of file component_base.hpp.

◆ ReportMalformedRequest()

virtual void server::handlers::HandlerBase::ReportMalformedRequest ( request::RequestBase & ) const
inlinevirtual

Produces response to a request unrecognized by the protocol based on provided generic response. Does not throw.

Reimplemented in server::handlers::HttpHandlerBase.

Definition at line 62 of file handler_base.hpp.


The documentation for this class was generated from the following file: