![]() |
NetFlex
0.0.0
C++11 HTTP Server Library.
|
#include <route.hpp>
Public Types | |
typedef std::function< void(const http::request &, http::response &)> | route_callback_t |
Public Member Functions | |
route (http::method m, const std::string &path, const route_callback_t &callback) | |
~route (void)=default | |
default dtor | |
route (const route &)=default | |
copy ctor | |
route & | operator= (const route &)=default |
assignment operator | |
bool | match (http::request &request) const |
void | dispatch (const http::request &request, http::response &response) const |
define a route for the server specify path, method and callback to be called path can be regex and contains params (like /articles/:id)
typedef std::function<void(const http::request&, http::response&)> netflex::routing::route::route_callback_t |
callback associated to the route, to be called on dispatch in case of match takes as parameter the request (const) and the response (to be modified)
netflex::routing::route::route | ( | http::method | m, |
const std::string & | path, | ||
const route_callback_t & | callback | ||
) |
ctor
m | HTTP verb of the route |
path | path of the route |
callback | callback to be called on dispatch in case of match |
void netflex::routing::route::dispatch | ( | const http::request & | request, |
http::response & | response | ||
) | const |
dispatch the request (and the response) to the pre-defined route callback
request | the http request |
response | the http response to return to the client |
bool netflex::routing::route::match | ( | http::request & | request | ) | const |
match the given http request with the underlying route to check if the requested route is this one