Skip to main content

filter

Attribute Macro filter 

Source
#[filter]
Expand description

Filters requests based on a boolean condition.

The function continues execution only if the provided code block returns true.

ยงUsage

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

#[route("/unknown_method")]
struct UnknownMethod;

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

    #[prologue_macros(
        filter(ctx.get_request().get_method().is_unknown()),
        response_body("unknown_method")
    )]
    async fn handle(self, ctx: &mut Context) {}
}

impl UnknownMethod {
    #[filter(true)]
    async fn filter_with_ref_self(&self, ctx: &mut Context) {}
}

#[filter(true)]
async fn standalone_filter_handler(ctx: &mut Context) {}