Skip to main content

http_version

Attribute Macro http_version 

Source
#[http_version]
Expand description

Restricts function execution to standard HTTP requests only.

This attribute macro ensures the decorated function only executes for standard HTTP requests, excluding WebSocket upgrades and other protocol upgrade requests.

ยงUsage

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

#[route("/http")]
struct HttpOnly;

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

    #[prologue_macros(http_version, response_body("http"))]
    async fn handle(self, ctx: &mut Context) {}
}

impl HttpOnly {
    #[http_version]
    async fn http_with_ref_self(&self, ctx: &mut Context) {}
}

#[http_version]
async fn standalone_http_handler(ctx: &mut Context) {}

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