Skip to main content

unknown_version

Attribute Macro unknown_version 

Source
#[unknown_version]
Expand description

Restricts function execution to requests with unknown HTTP versions only.

This attribute macro ensures the decorated function only executes when the incoming request uses an unrecognized or non-standard HTTP version (not HTTP/0.9, HTTP/1.0, HTTP/1.1, HTTP/2, or HTTP/3).

ยงUsage

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

#[route("/unknown_version")]
struct UnknownVersionHandler;

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

    #[prologue_macros(unknown_version, response_body("unknown version"))]
    async fn handle(self, ctx: &Context) {}
}

impl UnknownVersionHandler {
    #[unknown_version]
    async fn handle_unknown_with_ref_self(&self, ctx: &Context) {}
}

#[unknown_version]
async fn standalone_unknown_version_handler(ctx: &Context) {}

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