Skip to main content

reject

Attribute Macro reject 

Source
#[reject]
Expand description

Rejects requests based on a boolean condition.

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

ยงUsage

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

#[response_middleware(2)]
struct ResponseMiddleware2;

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

    #[prologue_macros(
        reject(ctx.get_request().get_upgrade_type().is_ws())
    )]
    async fn handle(self, ctx: &mut Context) {}
}

impl ResponseMiddleware2 {
    #[reject(false)]
    async fn reject_with_ref_self(&self, ctx: &mut Context) {}
}

#[reject(false)]
async fn standalone_reject_handler(ctx: &mut Context) {}