Mantis App v0.1.13
Loading...
Searching...
No Matches
mantis::RouteRegistry Class Reference

#include <http.h>

Public Member Functions

void add (const std::string &method, const std::string &path, RouteHandlerFunc handler, const std::vector< Middleware > &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__ = "mantis::RouteRegistry"
 

Detailed Description

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

Member Function Documentation

◆ add()

void mantis::RouteRegistry::add ( const std::string &  method,
const std::string &  path,
RouteHandlerFunc  handler,
const std::vector< Middleware > &  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 mantis::RouteHandler * mantis::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()

mantis::json mantis::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 mantis::RouteRegistry::__class_name__ = "mantis::RouteRegistry"

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