userver: easy::HttpBase Class Reference
Loading...
Searching...
No Matches
easy::HttpBase Class Referencefinal

#include <userver/easy.hpp>

Detailed Description

easy::HttpWith like class with erased dependencies information that should be used only in dependency registration functions; use easy::HttpWith if not making a new dependency class.

Examples
libraries/easy/samples/4_custom_dependency/main.cpp, and libraries/easy/samples/5_pg_service_template/src/main.cpp.

Definition at line 61 of file easy.hpp.

Public Types

using Callback = std::function<std::string(const server::http::HttpRequest&, const impl::DependenciesBase&)>
 

Public Member Functions

void DefaultContentType (http::ContentType content_type)
 Sets the default Content-Type header for all the routes.
 
void Route (std::string_view path, Callback &&func, std::initializer_list< server::http::HttpMethod > methods)
 Register an HTTP handler by path that supports the methods HTTP methods.
 
template<class Component >
bool TryAddComponent (std::string_view name, std::string_view config)
 Append a component to the component list of a service.
 
template<class Component >
bool TryAddComponent (std::string_view name)
 
void DbSchema (std::string_view schema)
 Stores the schema for further retrieval from GetDbSchema()
 
void Port (std::uint16_t port)
 Set the HTTP server listen port, default is 8080.
 
void LogLevel (logging::Level level)
 Set the logging level for the service.
 

Static Public Member Functions

static const std::string & GetDbSchema () noexcept
 

Member Typedef Documentation

◆ Callback

using easy::HttpBase::Callback = std::function<std::string(const server::http::HttpRequest&, const impl::DependenciesBase&)>

Definition at line 63 of file easy.hpp.

Member Function Documentation

◆ DbSchema()

void easy::HttpBase::DbSchema ( std::string_view schema)

Stores the schema for further retrieval from GetDbSchema()

Definition at line 180 of file easy.cpp.

◆ DefaultContentType()

void easy::HttpBase::DefaultContentType ( http::ContentType content_type)

Sets the default Content-Type header for all the routes.

Definition at line 157 of file easy.cpp.

◆ GetDbSchema()

const std::string & easy::HttpBase::GetDbSchema ( )
staticnoexcept
Returns
the last schema that was provided to the easy::HttpWith or easy::HttpBase

Definition at line 182 of file easy.cpp.

◆ LogLevel()

void easy::HttpBase::LogLevel ( logging::Level level)

Set the logging level for the service.

Definition at line 186 of file easy.cpp.

◆ Port()

void easy::HttpBase::Port ( std::uint16_t port)

Set the HTTP server listen port, default is 8080.

Definition at line 184 of file easy.cpp.

◆ Route()

void easy::HttpBase::Route ( std::string_view path,
Callback && func,
std::initializer_list< server::http::HttpMethod > methods )

Register an HTTP handler by path that supports the methods HTTP methods.

Definition at line 159 of file easy.cpp.

◆ TryAddComponent() [1/2]

template<class Component >
bool easy::HttpBase::TryAddComponent ( std::string_view name)
inline

Definition at line 84 of file easy.hpp.

◆ TryAddComponent() [2/2]

template<class Component >
bool easy::HttpBase::TryAddComponent ( std::string_view name,
std::string_view config )
inline

Append a component to the component list of a service.

Examples
libraries/easy/samples/4_custom_dependency/main.cpp, and libraries/easy/samples/5_pg_service_template/src/main.cpp.

Definition at line 73 of file easy.hpp.

Friends And Related Symbol Documentation

◆ HttpWith

template<class >
friend class HttpWith
friend

Definition at line 107 of file easy.hpp.


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