|
Orbit Framework
An ultra-modern, asynchronous, cross-platform C++ Web Framework.
|
Manages routing of HTTP requests to their appropriate handlers. More...
#include <Router.hpp>
Classes | |
| class | RouteBuilder |
| A builder class for fluent route configuration. More... | |
Public Member Functions | |
| Router (const std::string &prefix="", Router *parent=nullptr) | |
| Constructs a new Router. | |
| RouteBuilder | route (const std::string &path, http::HttpMethod method=http::HttpMethod::GET) |
| Initiates a route builder for a specific path and method. | |
| void | group (const std::string &prefix, std::function< void(Router &)> callback) |
| Creates a route group with a specific prefix. | |
| void | add_route (http::HttpMethod method, const std::string &path, RouteHandler handler) |
| void | add_route (http::HttpMethod method, const std::string &path, std::vector< Middleware > mws, RouteHandler handler) |
| void | add_route_with_meta (http::HttpMethod method, const std::string &path, std::vector< Middleware > mws, const openapi::RouteMetadata &meta, RouteHandler handler) |
| Router & | get (const std::string &path, RouteHandler handler) |
| Router & | get (const std::string &path, std::vector< Middleware > mws, RouteHandler handler) |
| Router & | post (const std::string &path, RouteHandler handler) |
| Router & | post (const std::string &path, std::vector< Middleware > mws, RouteHandler handler) |
| Router & | put (const std::string &path, RouteHandler handler) |
| Router & | put (const std::string &path, std::vector< Middleware > mws, RouteHandler handler) |
| Router & | patch (const std::string &path, RouteHandler handler) |
| Router & | patch (const std::string &path, std::vector< Middleware > mws, RouteHandler handler) |
| Router & | del (const std::string &path, RouteHandler handler) |
| Router & | del (const std::string &path, std::vector< Middleware > mws, RouteHandler handler) |
| Router & | options (const std::string &path, RouteHandler handler) |
| Router & | options (const std::string &path, std::vector< Middleware > mws, RouteHandler handler) |
| void | ws (const std::string &path, WsHandler handler) |
| void | use (Middleware m) |
| void | on_error (ErrorHandler handler) |
| void | route (http::HttpRequest &request, std::shared_ptr< http::ResponseWriter > response_writer) const |
| bool | has_ws_route (const std::string &path) const |
| WsHandler | get_ws_route (const std::string &path) const |
| bool | is_stream_route (http::HttpMethod method, const std::string &path) const |
| void | add_stream_route (http::HttpMethod method, const std::string &path, RouteHandler handler) |
Manages routing of HTTP requests to their appropriate handlers.
|
inline |
Constructs a new Router.
| prefix | The route prefix for this router. |
| parent | Pointer to the parent router, if any. |
| void routing::Router::add_route | ( | http::HttpMethod | method, |
| const std::string & | path, | ||
| RouteHandler | handler | ||
| ) |
| void routing::Router::add_route | ( | http::HttpMethod | method, |
| const std::string & | path, | ||
| std::vector< Middleware > | mws, | ||
| RouteHandler | handler | ||
| ) |
| void routing::Router::add_route_with_meta | ( | http::HttpMethod | method, |
| const std::string & | path, | ||
| std::vector< Middleware > | mws, | ||
| const openapi::RouteMetadata & | meta, | ||
| RouteHandler | handler | ||
| ) |
| void routing::Router::add_stream_route | ( | http::HttpMethod | method, |
| const std::string & | path, | ||
| RouteHandler | handler | ||
| ) |
| Router & routing::Router::del | ( | const std::string & | path, |
| RouteHandler | handler | ||
| ) |
| Router & routing::Router::del | ( | const std::string & | path, |
| std::vector< Middleware > | mws, | ||
| RouteHandler | handler | ||
| ) |
| Router & routing::Router::get | ( | const std::string & | path, |
| RouteHandler | handler | ||
| ) |
| Router & routing::Router::get | ( | const std::string & | path, |
| std::vector< Middleware > | mws, | ||
| RouteHandler | handler | ||
| ) |
| WsHandler routing::Router::get_ws_route | ( | const std::string & | path | ) | const |
| void routing::Router::group | ( | const std::string & | prefix, |
| std::function< void(Router &)> | callback | ||
| ) |
Creates a route group with a specific prefix.
| prefix | The URL prefix for the group. |
| callback | A function to configure routes within the group. |
| bool routing::Router::has_ws_route | ( | const std::string & | path | ) | const |
| bool routing::Router::is_stream_route | ( | http::HttpMethod | method, |
| const std::string & | path | ||
| ) | const |
| void routing::Router::on_error | ( | ErrorHandler | handler | ) |
| Router & routing::Router::options | ( | const std::string & | path, |
| RouteHandler | handler | ||
| ) |
| Router & routing::Router::options | ( | const std::string & | path, |
| std::vector< Middleware > | mws, | ||
| RouteHandler | handler | ||
| ) |
| Router & routing::Router::patch | ( | const std::string & | path, |
| RouteHandler | handler | ||
| ) |
| Router & routing::Router::patch | ( | const std::string & | path, |
| std::vector< Middleware > | mws, | ||
| RouteHandler | handler | ||
| ) |
| Router & routing::Router::post | ( | const std::string & | path, |
| RouteHandler | handler | ||
| ) |
| Router & routing::Router::post | ( | const std::string & | path, |
| std::vector< Middleware > | mws, | ||
| RouteHandler | handler | ||
| ) |
| Router & routing::Router::put | ( | const std::string & | path, |
| RouteHandler | handler | ||
| ) |
| Router & routing::Router::put | ( | const std::string & | path, |
| std::vector< Middleware > | mws, | ||
| RouteHandler | handler | ||
| ) |
|
inline |
Initiates a route builder for a specific path and method.
| path | The URL path. |
| method | The HTTP method (default is GET). |
| void routing::Router::route | ( | http::HttpRequest & | request, |
| std::shared_ptr< http::ResponseWriter > | response_writer | ||
| ) | const |
| void routing::Router::use | ( | Middleware | m | ) |
| void routing::Router::ws | ( | const std::string & | path, |
| WsHandler | handler | ||
| ) |