RESTful router. More...
#include <router.hpp>
Public Member Functions | |
| Router () | |
| template<typename... P> | |
| Router & | add (std::function< anch::rest::Response(const anch::rest::Request &, P...)> func, const std::string &path, const std::string &verb, const std::vector< std::string > &consumes, const std::vector< std::string > &produces) |
| template<typename... P> | |
| Router & | add (anch::rest::EndPoint &endpoint, std::function< anch::rest::Response(const anch::rest::Request &, P...)> func) |
| anch::rest::Response | execute (anch::rest::Request &request) noexcept |
RESTful router.
HTTP RESTful router which select function to execute according to its media types, HTTP verb and path.
To selected the endpoint to execute:
| anch::rest::Router::Router | ( | ) |
| Router & anch::rest::Router::add | ( | anch::rest::EndPoint & | endpoint, |
| std::function< anch::rest::Response(const anch::rest::Request &, P...)> | func ) |
Register new endpoint
| endpoint | the EndPoint |
| func | the function to execute for this endpoint |
this | anch::rest::RouterException | Endpoint already exists |
| Router & anch::rest::Router::add | ( | std::function< anch::rest::Response(const anch::rest::Request &, P...)> | func, |
| const std::string & | path, | ||
| const std::string & | verb, | ||
| const std::vector< std::string > & | consumes, | ||
| const std::vector< std::string > & | produces ) |
Register new endpoint
| func | the function to execute for this endpoint |
| path | the request path |
| verb | the HTTP verb |
| consumes | the accepted input media types |
| produces | the accepted output media types |
this | anch::rest::RouterException | Endpoint already exists |
|
noexcept |
Execute request
| request | the HTTP request |