#[try_get_http_request]Expand description
Wraps function body with HTTP stream processing.
This attribute macro generates code that wraps the function body with a check to see if data can be read from an HTTP stream. The function body is only executed if data is successfully read from the stream.
§Arguments
TokenStream: Optional variable name to store the read request data.TokenStream: The function item to be modified
§Returns
Returns a TokenStream containing the modified function with HTTP stream processing logic.
§Examples
Using no parameters:
use hyperlane::*;
use hyperlane_macros::*;
#[route("/try_get_http_request")]
struct HttpFromStreamTest;
impl ServerHook for HttpFromStreamTest {
async fn new(_: &mut Stream, _: &mut Context) -> Self {
Self
}
#[try_get_http_request]
async fn handle(self, stream: &mut Stream, ctx: &mut Context) -> Status {}
}Using with variable name:
use hyperlane::*;
use hyperlane_macros::*;
#[route("/try_get_http_request")]
struct HttpFromStreamTest;
impl ServerHook for HttpFromStreamTest {
async fn new(_: &mut Stream, _: &mut Context) -> Self {
Self
}
#[try_get_http_request(_request)]
async fn handle(self, stream: &mut Stream, ctx: &mut Context) -> Status {}
}
impl HttpFromStreamTest {
#[try_get_http_request(_request)]
async fn try_get_http_request_with_ref_self(&self, stream: &mut Stream, ctx: &mut Context) -> Status {}
}
#[try_get_http_request]
async fn standalone_try_get_http_request_handler(stream: &mut Stream, ctx: &mut Context) -> Status {}