#[route_params]Expand description
Extracts all route parameters into a collection variable.
This attribute macro retrieves all available route parameters from the URL path and makes them available as a collection for comprehensive route parameter access.
§Usage
use hyperlane::*;
use hyperlane_macros::*;
#[route("/route_params/:test")]
struct RouteParams;
impl ServerHook for RouteParams {
async fn new(_ctx: &Context) -> Self {
Self
}
#[response_body(&format!("request route params: {request_route_params:?}"))]
#[route_params(request_route_params)]
async fn handle(self, ctx: &Context) {}
}
impl RouteParams {
#[route_params(request_route_params)]
async fn route_params_with_ref_self(&self, ctx: &Context) {}
}
#[route_params(request_route_params)]
async fn standalone_route_params_handler(ctx: &Context) {}The macro accepts a variable name that will contain all route parameters. The variable will be available as a RouteParams type in the function scope.
§Multi-Parameter Usage
use hyperlane::*;
use hyperlane_macros::*;
#[route("/multi_params/:id")]
struct MultiParams;
impl ServerHook for MultiParams {
async fn new(_ctx: &Context) -> Self {
Self
}
#[response_body(&format!("params1: {params1:?}, params2: {params2:?}"))]
#[route_params(params1, params2)]
async fn handle(self, ctx: &Context) {}
}The macro accepts multiple variable names separated by commas.