Skip to main content

Module router

Module router 

Source
Expand description

Router for passing requests to their respective views.

§Examples

use cot::request::Request;
use cot::response::Response;
use cot::router::{Route, Router};

async fn home(request: Request) -> cot::Result<Response> {
    Ok(cot::reverse_redirect!(request, "get_page", page = 123)?)
}

async fn get_page(request: Request) -> cot::Result<Response> {
    unimplemented!()
}

let router = Router::with_urls([Route::with_handler_and_name(
    "/{page}", get_page, "get_page",
)]);

Modules§

method
Route to handlers based on HTTP methods.
path
Path matching and routing.

Structs§

Route
A route that can be used to route requests to their respective views.
Router
A router that can be used to route requests to their respective views.
RouterService
A service that routes requests to their respective views.
Urls
A helper structure to allow reversing URLs from a request handler.