#[attributes]Expand description
Extracts all attributes into a HashMap variable.
This attribute macro retrieves all available attributes from the request context and makes them available as a HashMap for comprehensive attribute access.
§Usage
use hyperlane::*;
use hyperlane_macros::*;
#[route("/attributes")]
struct Attributes;
impl ServerHook for Attributes {
async fn new(_ctx: &Context) -> Self {
Self
}
#[response_body(&format!("request attributes: {request_attributes:?}"))]
#[attributes(request_attributes)]
async fn handle(self, ctx: &Context) {}
}
impl Attributes {
#[attributes(request_attributes)]
async fn attributes_with_ref_self(&self, ctx: &Context) {}
}
#[attributes(request_attributes)]
async fn standalone_attributes_handler(ctx: &Context) {}The macro accepts a variable name that will contain a HashMap of all attributes. The variable will be available as a HashMap in the function scope.
§Multi-Parameter Usage
use hyperlane::*;
use hyperlane_macros::*;
#[route("/multi_attrs")]
struct MultiAttrs;
impl ServerHook for MultiAttrs {
async fn new(_ctx: &Context) -> Self {
Self
}
#[response_body(&format!("attrs1: {attrs1:?}, attrs2: {attrs2:?}"))]
#[attributes(attrs1, attrs2)]
async fn handle(self, ctx: &Context) {}
}The macro accepts multiple variable names separated by commas.