#[http_version]Expand description
Restricts function execution to standard HTTP requests only.
This attribute macro ensures the decorated function only executes for standard HTTP requests, excluding WebSocket upgrades and other protocol upgrade requests.
ยงUsage
use hyperlane::*;
use hyperlane_macros::*;
#[route("/http")]
struct HttpOnly;
impl ServerHook for HttpOnly {
async fn new(_: &mut Stream, _: &mut Context) -> Self {
Self
}
#[prologue_macros(http_version, response_body("http"))]
async fn handle(self, stream: &mut Stream, ctx: &mut Context) -> Status { Status::Continue }
}
impl HttpOnly {
#[http_version]
async fn http_with_ref_self(&self, stream: &mut Stream, ctx: &mut Context) -> Status { Status::Continue }
}
#[http_version]
async fn standalone_http_handler(stream: &mut Stream, ctx: &mut Context) -> Status { Status::Continue }The macro takes no parameters and should be applied directly to async functions
that accept a &mut Context parameter.