userver: easy::HttpWith< Dependency > Class Template Reference
Loading...
Searching...
No Matches
easy::HttpWith< Dependency > Class Template Referencefinal

#include <userver/easy.hpp>

Detailed Description

template<class Dependency = Dependencies<>>
class easy::HttpWith< Dependency >

Class for describing the service functionality in simple declarative way that generates static configs, applies schemas.

See also
Easy - library for single file prototyping
Examples
libraries/easy/samples/4_custom_dependency/main.cpp, and libraries/easy/samples/5_pg_service_template/src/main.cpp.

Definition at line 141 of file easy.hpp.

Classes

class  Callback
 

Public Member Functions

 HttpWith (int argc, const char *const argv[])
 
HttpWithDefaultContentType (http::ContentType content_type)
 Sets the default Content-Type header for all the routes.
 
HttpWithRoute (std::string_view path, Callback &&func, std::initializer_list< server::http::HttpMethod > methods={ server::http::HttpMethod::kGet, server::http::HttpMethod::kPost, server::http::HttpMethod::kDelete, server::http::HttpMethod::kPut, server::http::HttpMethod::kPatch, })
 Register an HTTP handler by path that supports the methods HTTP methods.
 
HttpWithGet (std::string_view path, Callback &&func)
 Register an HTTP handler by path that supports the HTTP GET method.
 
HttpWithPost (std::string_view path, Callback &&func)
 Register an HTTP handler by path that supports the HTTP POST method.
 
HttpWithDel (std::string_view path, Callback &&func)
 Register an HTTP handler by path that supports the HTTP DELETE method.
 
HttpWithPut (std::string_view path, Callback &&func)
 Register an HTTP handler by path that supports the HTTP PUT method.
 
HttpWithPatch (std::string_view path, Callback &&func)
 Register an HTTP handler by path that supports the HTTP PATCH method.
 
HttpWithDbSchema (std::string_view schema)
 
HttpWithPort (std::uint16_t port)
 Set the HTTP server listen port, default is 8080.
 
HttpWithLogLevel (logging::Level level)
 Set the logging level for the service.
 

Constructor & Destructor Documentation

◆ HttpWith()

template<class Dependency = Dependencies<>>
easy::HttpWith< Dependency >::HttpWith ( int argc,
const char *const argv[] )
inline

Definition at line 167 of file easy.hpp.

◆ ~HttpWith()

template<class Dependency = Dependencies<>>
easy::HttpWith< Dependency >::~HttpWith ( )
inline

Definition at line 170 of file easy.hpp.

Member Function Documentation

◆ DbSchema()

template<class Dependency = Dependencies<>>
HttpWith & easy::HttpWith< Dependency >::DbSchema ( std::string_view schema)
inline

◆ DefaultContentType()

template<class Dependency = Dependencies<>>
HttpWith & easy::HttpWith< Dependency >::DefaultContentType ( http::ContentType content_type)
inline

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

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

Definition at line 173 of file easy.hpp.

◆ Del()

template<class Dependency = Dependencies<>>
HttpWith & easy::HttpWith< Dependency >::Del ( std::string_view path,
Callback && func )
inline

Register an HTTP handler by path that supports the HTTP DELETE method.

Definition at line 207 of file easy.hpp.

◆ Get()

template<class Dependency = Dependencies<>>
HttpWith & easy::HttpWith< Dependency >::Get ( std::string_view path,
Callback && func )
inline

Register an HTTP handler by path that supports the HTTP GET method.

Definition at line 195 of file easy.hpp.

◆ LogLevel()

template<class Dependency = Dependencies<>>
HttpWith & easy::HttpWith< Dependency >::LogLevel ( logging::Level level)
inline

Set the logging level for the service.

Definition at line 237 of file easy.hpp.

◆ Patch()

template<class Dependency = Dependencies<>>
HttpWith & easy::HttpWith< Dependency >::Patch ( std::string_view path,
Callback && func )
inline

Register an HTTP handler by path that supports the HTTP PATCH method.

Definition at line 219 of file easy.hpp.

◆ Port()

template<class Dependency = Dependencies<>>
HttpWith & easy::HttpWith< Dependency >::Port ( std::uint16_t port)
inline

Set the HTTP server listen port, default is 8080.

Definition at line 231 of file easy.hpp.

◆ Post()

template<class Dependency = Dependencies<>>
HttpWith & easy::HttpWith< Dependency >::Post ( std::string_view path,
Callback && func )
inline

Register an HTTP handler by path that supports the HTTP POST method.

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

Definition at line 201 of file easy.hpp.

◆ Put()

template<class Dependency = Dependencies<>>
HttpWith & easy::HttpWith< Dependency >::Put ( std::string_view path,
Callback && func )
inline

Register an HTTP handler by path that supports the HTTP PUT method.

Definition at line 213 of file easy.hpp.

◆ Route()

template<class Dependency = Dependencies<>>
HttpWith & easy::HttpWith< Dependency >::Route ( std::string_view path,
Callback && func,
std::initializer_list< server::http::HttpMethod > methods = { server::http::HttpMethod::kGet, server::http::HttpMethod::kPost, server::http::HttpMethod::kDelete, server::http::HttpMethod::kPut, server::http::HttpMethod::kPatch, } )
inline

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

Definition at line 178 of file easy.hpp.


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