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
samples/easy/4_custom_dependency/main.cpp, and samples/easy/5_pg_service_template/src/main.cpp.

Definition at line 201 of file easy.hpp.

Classes

class  Callback

Public Member Functions

 HttpWith (int argc, const char *const argv[])
HttpWith & DefaultContentType (http::ContentType content_type)
 Sets the default Content-Type header for all the routes.
HttpWith & 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, })
 Register an HTTP handler by path that supports the methods HTTP methods.
HttpWith & Get (std::string_view path, Callback &&func)
 Register an HTTP handler by path that supports the HTTP GET method.
HttpWith & Post (std::string_view path, Callback &&func)
 Register an HTTP handler by path that supports the HTTP POST method.
HttpWith & Del (std::string_view path, Callback &&func)
 Register an HTTP handler by path that supports the HTTP DELETE method.
HttpWith & Put (std::string_view path, Callback &&func)
 Register an HTTP handler by path that supports the HTTP PUT method.
HttpWith & Patch (std::string_view path, Callback &&func)
 Register an HTTP handler by path that supports the HTTP PATCH method.
HttpWith & DbSchema (std::string_view schema)
 Stores the schema for further retrieval from GetDbSchema().
HttpWith & Port (std::uint16_t port)
 Set the HTTP server listen port, default is 8080.
HttpWith & LogLevel (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 230 of file easy.hpp.

◆ ~HttpWith()

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

Definition at line 235 of file easy.hpp.

Member Function Documentation

◆ DbSchema()

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

Stores the schema for further retrieval from GetDbSchema().

Examples
samples/easy/4_custom_dependency/main.cpp.

Definition at line 290 of file easy.hpp.

◆ 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
samples/easy/4_custom_dependency/main.cpp, and samples/easy/5_pg_service_template/src/main.cpp.

Definition at line 238 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 272 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 260 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 302 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 284 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 296 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
samples/easy/4_custom_dependency/main.cpp, and samples/easy/5_pg_service_template/src/main.cpp.

Definition at line 266 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 278 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 243 of file easy.hpp.


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