host

Attribute Macro host 

Source
#[host]
Expand description

Restricts function execution to requests with a specific host.

This attribute macro ensures the decorated function only executes when the incoming request has a host header that matches the specified value. Requests with different or missing host headers will be filtered out.

ยงUsage

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

#[host("localhost")]
async fn handle_example_com(ctx: Context) {
    // Function body for localhost requests
}

#[host("api.localhost")]
async fn handle_api_subdomain(ctx: Context) {
    // Function body for api.localhost requests
}

The macro accepts a string literal specifying the expected host value and should be applied to async functions that accept a Context parameter.