![]() |
Mantis App v0.1.13
|
#include <http.h>
Public Member Functions | |
HttpUnit () | |
void | Get (const std::string &path, RouteHandlerFunc handler, std::initializer_list< Middleware > middlewares={}) |
void | Post (const std::string &path, RouteHandlerFunc handler, std::initializer_list< Middleware > middlewares={}) |
void | Patch (const std::string &path, RouteHandlerFunc handler, std::initializer_list< Middleware > middlewares={}) |
void | Delete (const std::string &path, RouteHandlerFunc handler, std::initializer_list< Middleware > middlewares={}) |
bool | listen (const std::string &host, const int &port) |
Bind to a port and start listening for requests. | |
void | close () |
Close the HTTP server connection. | |
RouteRegistry & | routeRegistry () |
Fetch the underlying route registry, check. | |
httplib::Server & | server () |
Static Public Member Functions | |
static Context & | context () |
Public Attributes | |
const std::string | _class_ = "mantis::HttpUnit" |
Class wrapper around httplib methods allowing for injection of the middleware and context functionality. By default, httplib supports pre/post global middlewares, we're therefore adding a layer to scope middlewares to specific routes.
Also, to allow sharing data between middlewares and handler func, we are adding Context in the handler functions.
mantis::HttpUnit::HttpUnit | ( | ) |
void mantis::HttpUnit::close | ( | ) |
Close the HTTP server connection.
|
static |
void mantis::HttpUnit::Delete | ( | const std::string & | path, |
RouteHandlerFunc | handler, | ||
std::initializer_list< Middleware > | middlewares = {} |
||
) |
void mantis::HttpUnit::Get | ( | const std::string & | path, |
RouteHandlerFunc | handler, | ||
std::initializer_list< Middleware > | middlewares = {} |
||
) |
bool mantis::HttpUnit::listen | ( | const std::string & | host, |
const int & | port | ||
) |
Bind to a port and start listening for requests.
host | HTTP server host. |
port | HTTP server port. |
void mantis::HttpUnit::Patch | ( | const std::string & | path, |
RouteHandlerFunc | handler, | ||
std::initializer_list< Middleware > | middlewares = {} |
||
) |
void mantis::HttpUnit::Post | ( | const std::string & | path, |
RouteHandlerFunc | handler, | ||
std::initializer_list< Middleware > | middlewares = {} |
||
) |
mantis::RouteRegistry & mantis::HttpUnit::routeRegistry | ( | ) |
Fetch the underlying route registry, check.
httplib::Server & mantis::HttpUnit::server | ( | ) |
const std::string mantis::HttpUnit::_class_ = "mantis::HttpUnit" |