#[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.
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: The buffer to read from the HTTP stream.TokenStream: The function item to be modified
§Returns
Returns a TokenStream containing the modified function with HTTP stream processing logic.
§Examples
Using with epilogue_macros:
use hyperlane::*;
use hyperlane_macros::*;
#[route("/http_from_stream")]
struct HttpFromStreamTest;
impl ServerHook for HttpFromStreamTest {
async fn new(_ctx: &Context) -> Self {
Self
}
#[epilogue_macros(
request_query("test" => request_query_option),
response_body(&format!("request query: {request_query_option:?}")),
send,
http_from_stream(RequestConfig::default())
)]
async fn handle(self, ctx: &Context) {}
}Using with variable name:
use hyperlane::*;
use hyperlane_macros::*;
#[route("/http_from_stream")]
struct HttpFromStreamTest;
impl ServerHook for HttpFromStreamTest {
async fn new(_ctx: &Context) -> Self {
Self
}
#[epilogue_macros(
http_from_stream(_request)
)]
async fn handle(self, ctx: &Context) {}
}
impl HttpFromStreamTest {
#[http_from_stream(_request)]
async fn http_from_stream_with_ref_self(&self, ctx: &Context) {}
}
#[http_from_stream]
async fn standalone_http_from_stream_handler(ctx: &Context) {}