Github   Telegram
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | List of all members
server::handlers::HttpHandlerStatic Class Referencefinal

Handler that returns HTTP 200 if file exist and returns file data with mapped content/type. More...

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

+ Inheritance diagram for server::handlers::HttpHandlerStatic:
+ Collaboration diagram for server::handlers::HttpHandlerStatic:

Public Member Functions

 HttpHandlerStatic (const components::ComponentConfig &config, const components::ComponentContext &context)
 
std::string GetContentType (std::string_view extension) const
 
std::string HandleRequestThrow (const http::HttpRequest &request, request::RequestContext &) const override
 
 HttpHandlerBase (const components::ComponentConfig &config, const components::ComponentContext &component_context, bool is_monitor=false)
 
- Public Member Functions inherited from server::handlers::HttpHandlerBase
 HttpHandlerBase (const components::ComponentConfig &config, const components::ComponentContext &component_context, bool is_monitor=false)
 
void HandleRequest (request::RequestBase &request, request::RequestContext &context) const override
 
void ReportMalformedRequest (request::RequestBase &request) const final
 
virtual const std::string & HandlerName () const
 
const std::vector< http::HttpMethod > & GetAllowedMethods () const
 
virtual logging::Level GetLogLevelForResponseStatus (http::HttpStatus status) const
 
virtual FormattedErrorData GetFormattedExternalErrorBody (const CustomHandlerException &exc) const
 
std::string GetResponseDataForLoggingChecked (const http::HttpRequest &request, request::RequestContext &context, const std::string &response_data) const
 
- Public Member Functions inherited from server::handlers::HandlerBase
 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. More...
 
const HandlerConfigGetConfig () const
 Returns handler config.
 
- Public Member Functions inherited from components::LoggableComponentBase
 LoggableComponentBase (const ComponentConfig &, const ComponentContext &)
 
 LoggableComponentBase (LoggableComponentBase &&)=delete
 
 LoggableComponentBase (const LoggableComponentBase &)=delete
 
 ~LoggableComponentBase () override=default
 
ComponentHealth GetComponentHealth () const override
 
void OnLoadingCancelled () override
 
void OnAllComponentsLoaded () override
 
void OnAllComponentsAreStopping () override
 

Static Public Attributes

static constexpr std::string_view kName = "handler-static"
 

Additional Inherited Members

- Static Public Member Functions inherited from server::handlers::HttpHandlerBase
static yaml_config::Schema GetStaticConfigSchema ()
 
- Static Public Member Functions inherited from server::handlers::HandlerBase
static yaml_config::Schema GetStaticConfigSchema ()
 
- Static Public Member Functions inherited from components::LoggableComponentBase
static yaml_config::Schema GetStaticConfigSchema ()
 
- Protected Types inherited from server::handlers::HandlerBase
using HandlerErrorCode = handlers::HandlerErrorCode
 
using InternalMessage = handlers::InternalMessage
 
using ExternalBody = handlers::ExternalBody
 
using ClientError = handlers::ClientError
 
using InternalServerError = handlers::InternalServerError
 
- Protected Member Functions inherited from server::handlers::HttpHandlerBase
void ThrowUnsupportedHttpMethod (const http::HttpRequest &request) const
 
virtual std::string HandleRequestThrow (const http::HttpRequest &request, request::RequestContext &context) const
 
virtual void OnRequestCompleteThrow (const http::HttpRequest &, request::RequestContext &) const
 
virtual void HandleStreamRequest (const server::http::HttpRequest &, server::request::RequestContext &, server::http::ResponseBodyStream &) const
 
virtual bool IsStreamed () const
 
virtual bool IsMethodStatisticIncluded () const
 
virtual bool NeedCheckAuth () const
 
virtual std::string GetRequestBodyForLogging (const http::HttpRequest &request, request::RequestContext &context, const std::string &request_body) const
 Override it if you need a custom request body logging. More...
 
virtual std::string GetResponseDataForLogging (const http::HttpRequest &request, request::RequestContext &context, const std::string &response_data) const
 Override it if you need a custom response data logging. More...
 
virtual void ParseRequestData (const http::HttpRequest &, request::RequestContext &) const
 
virtual std::string GetMetaType (const http::HttpRequest &) const
 

Detailed Description

Handler that returns HTTP 200 if file exist and returns file data with mapped content/type.

Dynamic config

Userver HTTP Handlers.

Static options:

Inherits all the options from server::handlers::HttpHandlerBase and adds the following ones:

Name Description Default value
fs-cache-component Name of the FsCache component fs-cache-component

Example usage:

int main(int argc, char* argv[]) {
const auto component_list =
.Append<components::FsCache>("fs-cache-main")
.Append<server::handlers::HttpHandlerStatic>();
return utils::DaemonMain(argc, argv, component_list);
}

Definition at line 41 of file http_handler_static.hpp.

Member Function Documentation

◆ HandleRequestThrow()

std::string server::handlers::HttpHandlerStatic::HandleRequestThrow ( const http::HttpRequest request,
request::RequestContext  
) const
overridevirtual

Reimplemented from server::handlers::HttpHandlerBase.

Member Data Documentation

◆ kName

constexpr std::string_view server::handlers::HttpHandlerStatic::kName = "handler-static"
staticconstexpr

Definition at line 43 of file http_handler_static.hpp.


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