#[request_path]Expand description
Extracts the HTTP request path into a variable.
This attribute macro retrieves the request path from the HTTP request and makes it available as a variable. The path represents the URL path portion of the request.
ยงUsage
use hyperlane::*;
use hyperlane_macros::*;
#[route("/request_path")]
struct RequestPathTest;
impl ServerHook for RequestPathTest {
async fn new(_ctx: &Context) -> Self {
Self
}
#[response_body(&format!("Request Path: {request_path}"))]
#[request_path(request_path)]
async fn handle(self, ctx: &Context) {}
}
impl RequestPathTest {
#[request_path(request_path)]
async fn request_path_with_ref_self(&self, ctx: &Context) {}
}
#[request_path(request_path)]
async fn standalone_request_path_handler(ctx: &Context) {}The macro accepts a variable name that will contain the HTTP request path. The variable will be available as a RequestPath type in the function scope.