MantisBase v0.3.4
Loading...
Searching...
No Matches
mb::RouteRegistry Class Reference

#include <route_registry.h>

Public Member Functions

void add (const std::string &method, const std::string &path, HandlerFn handler, const Middlewares &middlewares)
 Add new route to the registry.
 
void add (const std::string &method, const std::string &path, HandlerWithContentReaderFn handler, const Middlewares &middlewares)
 Add new route to the registry.
 
const RouteHandlerfind (const std::string &method, const std::string &path) const
 Find a route in the registry matching given method and route.
 
json remove (const std::string &method, const std::string &path)
 Remove find and remove existing route + path pair from the registry.
 

Public Attributes

const std::string __class_name__ = "mb::RouteRegistry"
 

Detailed Description

Class to manage route registration, removal and dynamic checks on request.

Member Function Documentation

◆ add() [1/2]

void mb::RouteRegistry::add ( const std::string &  method,
const std::string &  path,
HandlerFn  handler,
const Middlewares middlewares 
)

Add new route to the registry.

Parameters
methodRequest method, i.e. GET, POST, PATCH, etc.
pathRequest path.
handlerRequest handler function.
middlewaresList of
See also
Middleware to be imposed on this request *

◆ add() [2/2]

void mb::RouteRegistry::add ( const std::string &  method,
const std::string &  path,
HandlerWithContentReaderFn  handler,
const Middlewares middlewares 
)

Add new route to the registry.

Parameters
methodRequest method, i.e. GET, POST, PATCH, etc.
pathRequest path.
handlerRequest handler function.
middlewaresList of
See also
Middleware to be imposed on this request *

◆ find()

const RouteHandler * mb::RouteRegistry::find ( const std::string &  method,
const std::string &  path 
) const

Find a route in the registry matching given method and route.

Parameters
methodRequest method.
pathRequest path.
Returns
See also
RouteHandler struct having middlewares and handler func.

◆ remove()

json mb::RouteRegistry::remove ( const std::string &  method,
const std::string &  path 
)

Remove find and remove existing route + path pair from the registry.

Parameters
methodRequest method
pathRequest path
Returns
JSON Error object, error value contains data if operation fails.

Member Data Documentation

◆ __class_name__

const std::string mb::RouteRegistry::__class_name__ = "mb::RouteRegistry"

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