macro_rules! reverse_redirect {
($request:expr, $view_name:literal $(, $($key:ident = $value:expr),*)?) => { ... };
}Expand description
Get a URL for a view by its registered name and given params and return a response with a redirect.
This macro is a shorthand for creating a response with a redirect to a URL
generated by the reverse! macro.
§Return value
Returns a cot::Result<Response> that contains the URL for
the view. You will typically want to append ? to the macro call to get the
Response object.
§Examples
use cot::request::Request;
use cot::response::Response;
use cot::reverse_redirect;
use cot::router::{Route, Router};
async fn infinite_loop(request: Request) -> cot::Result<Response> {
Ok(reverse_redirect!(request, "home")?)
}
let router = Router::with_urls([Route::with_handler_and_name("/", infinite_loop, "home")]);