Skip to main content

unknown_upgrade_type

Attribute Macro unknown_upgrade_type 

Source
#[unknown_upgrade_type]
Expand description

Restricts function execution to requests with unknown protocol upgrade types only.

This attribute macro ensures the decorated function only executes when the incoming request uses an unrecognized or non-standard protocol upgrade type (not WebSocket, h2c, or TLS).

ยงUsage

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

#[route("/unknown_upgrade_type")]
struct UnknownUpgrade;

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

    #[prologue_macros(unknown_upgrade_type, response_body("unknown upgrade type"))]
    async fn handle(self, ctx: &mut Context) {}
}

impl UnknownUpgrade {
    #[unknown_upgrade_type]
    async fn unknown_upgrade_type_with_ref_self(&self, ctx: &mut Context) {}
}

#[unknown_upgrade_type]
async fn standalone_unknown_upgrade_type_handler(ctx: &mut Context) {}

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