Skip to main content

h2c_upgrade_type

Attribute Macro h2c_upgrade_type 

Source
#[h2c_upgrade_type]
Expand description

Restricts function execution to HTTP/2 Cleartext (h2c_upgrade_type) requests only.

This attribute macro ensures the decorated function only executes for HTTP/2 cleartext requests that use the h2c_upgrade_type upgrade mechanism.

ยงUsage

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

#[route("/h2c_upgrade_type")]
struct H2c;

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

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

impl H2c {
    #[h2c_upgrade_type]
    async fn h2c_upgrade_type_with_ref_self(&self, ctx: &Context) {}
}

#[h2c_upgrade_type]
async fn standalone_h2c_upgrade_type_handler(ctx: &Context) {}

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