#[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 no parameters (default buffer size):
use hyperlane::*;
use hyperlane_macros::*;
#[http_from_stream]
async fn handle_data(ctx: Context) {
// Process data from HTTP stream with default buffer size
}Basic usage with buffer size:
use hyperlane::*;
use hyperlane_macros::*;
#[http_from_stream(1024)]
async fn handle_data(ctx: Context) {
// Process data from stream with 1024 byte buffer
}Using a variable name for the data:
use hyperlane::*;
use hyperlane_macros::*;
#[http_from_stream(data)]
async fn handle_data(ctx: Context) {
// Data will be available in the `data` variable
}Using both buffer size and variable name:
use hyperlane::*;
use hyperlane_macros::*;
#[http_from_stream(1024, payload)]
async fn handle_large_data(ctx: Context) {
// Process large data with 1024 byte buffer, available in `payload` variable
}