reject_host

Attribute Macro reject_host 

Source
#[reject_host]
Expand description

Reject requests that have no host header.

This attribute macro ensures the decorated function only executes when the incoming request has a host header present. Requests without a host header will be filtered out.

ยงUsage

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

#[route("/reject_host")]
struct RejectHost;

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

    #[prologue_macros(
        reject_host("filter.localhost"),
        response_body("host filter string literal")
    )]
    async fn handle(self, ctx: &Context) {}
}

impl RejectHost {
    #[reject_host("filter.localhost")]
    async fn reject_host_with_ref_self(&self, ctx: &Context) {}
}

#[reject_host("filter.localhost")]
async fn standalone_reject_host_handler(ctx: &Context) {}

The macro takes no parameters and should be applied directly to async functions that accept a &Context parameter.