#[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(_ctx: &Context) -> Self {
Self
}
#[response_body(&format!("HTTP Version: {http_version}"))]
#[request_version(http_version)]
async fn handle(self, ctx: &Context) {}
}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.