Skip to main content

is_http2_version

Attribute Macro is_http2_version 

Source
#[is_http2_version]
Expand description

Restricts function execution to HTTP/2 requests only.

This attribute macro ensures the decorated function only executes for HTTP/2 protocol requests.

ยงUsage

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

#[route("/is_http2_version")]
struct Http2;

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

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

impl Http2 {
    #[is_http2_version]
    async fn http2_version_with_ref_self(&self, stream: &mut Stream, ctx: &mut Context) -> Status { Status::Continue }
}

#[is_http2_version]
async fn standalone_http2_version_handler(stream: &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.