![]() |
Mantis App v0.2.8
|
#include <http.h>
Public Member Functions | |
HttpUnit () | |
~HttpUnit () | |
void | Get (const std::string &path, const RouteHandlerFunc &handler, std::initializer_list< Middleware > middlewares={}) |
void | Post (const std::string &path, const RouteHandlerFunc &handler, std::initializer_list< Middleware > middlewares={}) |
void | Post (const std::string &path, const RouteHandlerFuncWithContentReader &handler, std::initializer_list< Middleware > middlewares={}) |
void | Patch (const std::string &path, const RouteHandlerFunc &handler, std::initializer_list< Middleware > middlewares={}) |
void | Patch (const std::string &path, const RouteHandlerFuncWithContentReader &handler, std::initializer_list< Middleware > middlewares={}) |
void | Delete (const std::string &path, const 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 () |
Get a reference to the httplib::Server instance. | |
Static Public Member Functions | |
static Context & | context () |
static std::string | hashMultipartMetadata (const httplib::FormData &data) |
Generate hash for the file metadata. | |
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 | ( | ) |
mantis::HttpUnit::~HttpUnit | ( | ) |
void mantis::HttpUnit::close | ( | ) |
Close the HTTP server connection.
|
static |
void mantis::HttpUnit::Delete | ( | const std::string & | path, |
const RouteHandlerFunc & | handler, | ||
std::initializer_list< Middleware > | middlewares = {} |
||
) |
void mantis::HttpUnit::Get | ( | const std::string & | path, |
const RouteHandlerFunc & | handler, | ||
std::initializer_list< Middleware > | middlewares = {} |
||
) |
|
static |
Generate hash for the file metadata.
data | Multipart file reference |
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, |
const RouteHandlerFunc & | handler, | ||
std::initializer_list< Middleware > | middlewares = {} |
||
) |
void mantis::HttpUnit::Patch | ( | const std::string & | path, |
const RouteHandlerFuncWithContentReader & | handler, | ||
std::initializer_list< Middleware > | middlewares = {} |
||
) |
void mantis::HttpUnit::Post | ( | const std::string & | path, |
const RouteHandlerFunc & | handler, | ||
std::initializer_list< Middleware > | middlewares = {} |
||
) |
void mantis::HttpUnit::Post | ( | const std::string & | path, |
const RouteHandlerFuncWithContentReader & | handler, | ||
std::initializer_list< Middleware > | middlewares = {} |
||
) |
mantis::RouteRegistry & mantis::HttpUnit::routeRegistry | ( | ) |
Fetch the underlying route registry, check.
httplib::Server & mantis::HttpUnit::server | ( | ) |
Get a reference to the httplib::Server instance.
const std::string mantis::HttpUnit::_class_ = "mantis::HttpUnit" |