referer

Attribute Macro referer 

Source
#[referer]
Expand description

Restricts function execution to requests with a specific referer.

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

ยงUsage

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

#[route("/referer")]
struct Referer;

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

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

impl Referer {
    #[referer("http://localhost")]
    async fn referer_with_ref_self(&self, ctx: &Context) {}
}

#[referer("http://localhost")]
async fn standalone_referer_handler(ctx: &Context) {}

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