request_headers

Attribute Macro request_headers 

Source
#[request_headers]
Expand description

Extracts all HTTP request headers into a collection variable.

This attribute macro retrieves all available HTTP request headers from the request and makes them available as a collection for comprehensive request header access.

ยงUsage

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

#[route("/request_headers")]
struct RequestHeaders;

impl ServerHook for RequestHeaders {
    async fn new(_ctx: &Context) -> Self {
        Self
    }

    #[prologue_macros(
        request_headers(request_headers),
        response_body(&format!("request headers: {request_headers:?}")),
        send
    )]
    async fn handle(self, ctx: &Context) {}
}

impl RequestHeaders {
    #[request_headers(request_headers)]
    async fn request_headers_with_ref_self(&self, ctx: &Context) {}
}

#[request_headers(request_headers)]
async fn standalone_request_headers_handler(ctx: &Context) {}

The macro accepts a variable name that will contain all HTTP request headers. The variable will be available as a collection in the function scope.