NetFlex  0.0.0
C++11 HTTP Server Library.
Public Types | Public Member Functions | List of all members
netflex::routing::route Class Reference

#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
 
routeoperator= (const route &)=default
 assignment operator
 
bool match (http::request &request) const
 
void dispatch (const http::request &request, http::response &response) const
 

Detailed Description

define a route for the server specify path, method and callback to be called path can be regex and contains params (like /articles/:id)

Member Typedef Documentation

◆ 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)

Constructor & Destructor Documentation

◆ route()

netflex::routing::route::route ( http::method  m,
const std::string &  path,
const route_callback_t callback 
)

ctor

Parameters
mHTTP verb of the route
pathpath of the route
callbackcallback to be called on dispatch in case of match

Member Function Documentation

◆ dispatch()

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

Parameters
requestthe http request
responsethe http response to return to the client

◆ match()

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

Returns
true if match, false otherwise

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