request_header

Attribute Macro request_header 

Source
#[request_header]
Expand description

Extracts a specific HTTP request header into a variable.

This attribute macro retrieves a specific HTTP request header by name and makes it available as a variable. Header values are extracted from the request request headers collection.

ยงUsage

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

#[request_header(HOST => host_request_header)]
async fn handle_with_host(ctx: Context) {
    if let Some(host) = host_request_header {
        // Use the host request_header value
    }
}

#[request_header("Content-Type" => content_type)]
async fn handle_with_content_type(ctx: Context) {
    if let Some(ct) = content_type {
        // Use the content type request_header
    }
}

The macro accepts a request header name-to-variable mapping in the format HEADER_NAME => variable_name or "Header-Name" => variable_name. The variable will be available as an Option<String>.