#[http_from_stream]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("/http_from_stream")]
struct HttpFromStreamTest;
impl ServerHook for HttpFromStreamTest {
async fn new(_ctx: &mut Context) -> Self {
Self
}
#[http_from_stream]
async fn handle(self, ctx: &mut Context) {}
}Using with variable name:
use hyperlane::*;
use hyperlane_macros::*;
#[route("/http_from_stream")]
struct HttpFromStreamTest;
impl ServerHook for HttpFromStreamTest {
async fn new(_ctx: &mut Context) -> Self {
Self
}
#[http_from_stream(_request)]
async fn handle(self, ctx: &mut Context) {}
}
impl HttpFromStreamTest {
#[http_from_stream(_request)]
async fn http_from_stream_with_ref_self(&self, ctx: &mut Context) {}
}
#[http_from_stream]
async fn standalone_http_from_stream_handler(ctx: &mut Context) {}