route_param

Attribute Macro route_param 

Source
#[route_param]
Expand description

Extracts a specific route parameter into a variable.

This attribute macro retrieves a specific route parameter by key and makes it available as a variable. Route parameters are extracted from the URL path segments.

ยงUsage

use hyperlane::*;
use hyperlane_macros::*;

// For route like "/users/{id}"
#[route_param("id" => user_id)]
async fn get_user(ctx: Context) {
    if let Some(id) = user_id {
        // Use the route parameter
    }
}

The macro accepts a key-to-variable mapping in the format "key" => variable_name. The variable will be available as an Option<String> in the function scope.