reject_referer

Attribute Macro reject_referer 

Source
#[reject_referer]
Expand description

Reject requests that have a specific referer header.

This attribute macro ensures the decorated function only executes when the incoming request does not have a referer header that matches the specified value. Requests with the matching referer header will be filtered out.

ยงUsage

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

#[route("/reject_referer")]
struct RejectReferer;

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

    #[prologue_macros(
        reject_referer("http://localhost"),
        response_body("referer filter string literal")
    )]
    async fn handle(self, ctx: &Context) {}
}

The macro accepts a string literal specifying the referer value to filter out and should be applied to async functions that accept a &Context parameter.