ゴミ箱
|
#include <router.hpp>
Classes | |
struct | Context |
class | Route |
Public Types | |
typedef std::unordered_map< std::string, std::string > | matches |
typedef std::function< void(Context &&)> | router_handler |
Type of route's handler. More... | |
Public Member Functions | |
Router () noexcept | |
Initializes router. More... | |
Router & | add_route (Method method, const char *route, router_handler fn) |
bool | dispatch (const boost::asio::ip::tcp::socket &socket, const dynamic_request &request, dynamic_response &response) const noexcept |
bool | is_method_used (boost::beast::http::verb method) const noexcept |
HTTP Router class
typedef std::unordered_map<std::string, std::string> http::Router::matches |
typedef std::function<void(Context&&)> http::Router::router_handler |
Type of route's handler.
|
noexcept |
Initializes router.
Router & Router::add_route | ( | Method | method, |
const char * | route, | ||
router_handler | fn | ||
) |
Adds route's handler.
method | Router's method. |
route | String with URI path relative to host <host:port></route> |
fn | Handler for route. |
|
noexcept |
Dispatches Beast HTTP request.
socket | Boost asio's socket. |
request | Beast HTTP request. |
response | Beast HTTP response. |
true | If corresponding handler is found. |
false | Otherwise. |
|
noexcept |