Skip to main content

response_version

Attribute Macro response_version 

Source
#[response_version]
Expand description

Sets the HTTP response version.

This attribute macro configures the HTTP response version that will be sent with the response. The version can be provided as a variable or code block.

ยงUsage

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

#[request_middleware]
struct RequestMiddleware;

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

    #[epilogue_macros(
        response_status_code(200),
        response_version(HttpVersion::Http1_1),
        response_header(SERVER => HYPERLANE)
    )]
    async fn handle(self, ctx: &mut Context) {}
}

impl RequestMiddleware {
    #[response_version(HttpVersion::Http2)]
    async fn response_version_with_ref_self(&self, ctx: &mut Context) {}
}

#[response_version(HttpVersion::Http1_0)]
async fn standalone_response_version_handler(ctx: &mut Context) {}

The macro accepts a variable or code block for the response version and should be applied to async functions that accept a &mut Context parameter.