Skip to main content

tls_upgrade_type

Attribute Macro tls_upgrade_type 

Source
#[tls_upgrade_type]
Expand description

Restricts function execution to TLS-encrypted requests only.

This attribute macro ensures the decorated function only executes for requests that use TLS/SSL encryption on the connection.

ยงUsage

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

#[route("/tls_upgrade_type")]
struct Tls;

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

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

impl Tls {
    #[tls_upgrade_type]
    async fn tls_upgrade_type_with_ref_self(&self, ctx: &Context) {}
}

#[tls_upgrade_type]
async fn standalone_tls_upgrade_type_handler(ctx: &Context) {}

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