Skip to main content

is_connect_method

Attribute Macro is_connect_method 

Source
#[is_connect_method]
Expand description

Restricts function execution to HTTP CONNECT requests only.

This attribute macro ensures the decorated function only executes when the incoming request uses the CONNECT HTTP method. Requests with other methods will be filtered out.

ยงUsage

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

#[route("/is_connect_method")]
struct Connect;

impl ServerHook for Connect {
    async fn new(_: &mut Stream, _: &mut Context) -> Self {
        Self
    }

    #[prologue_macros(is_connect_method, response_body("is_connect_method"))]
    async fn handle(self, _: &mut Stream, ctx: &mut Context) -> Status { Status::Continue }
}

impl Connect {
    #[is_connect_method]
    async fn connect_with_ref_self(&self, _: &mut Stream, ctx: &mut Context) -> Status { Status::Continue }
}

#[is_connect_method]
async fn standalone_connect_handler(_: &mut Stream, ctx: &mut Context) -> Status { Status::Continue }

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