#[request_version]Expand description
Extracts the HTTP request version into a variable.
This attribute macro retrieves the HTTP version from the request and makes it available as a variable. The version represents the HTTP protocol version used.
ยงUsage
use hyperlane::*;
use hyperlane_macros::*;
#[route("/request_version")]
struct RequestVersionTest;
impl ServerHook for RequestVersionTest {
async fn new(_: &mut Stream, _: &mut Context) -> Self {
Self
}
#[response_body(&format!("HTTP Version: {is_http_version}"))]
#[request_version(is_http_version)]
async fn handle(self, stream: &mut Stream, ctx: &mut Context) -> Status { Status::Continue }
}
impl RequestVersionTest {
#[request_version(is_http_version)]
async fn request_version_with_ref_self(&self, stream: &mut Stream, ctx: &mut Context) -> Status { Status::Continue }
}
#[request_version(is_http_version)]
async fn standalone_request_version_handler(stream: &mut Stream, ctx: &mut Context) -> Status { Status::Continue }The macro accepts a variable name that will contain the HTTP request version. The variable will be available as a RequestVersion type in the function scope.