Expand description
reqwest-sse is a lightweight Rust library that extends
reqwest by adding native support of
Server-Sent Events (SSE)
. It introduces the EventSource trait, which extends reqwest’s Response
type with an ergonomic .events() method. This method transforms the
response body into an asynchronous Stream of SSE Events, enabling
seamless integration of real-time event handling in applications
using the familiar reqwest HTTP client and the StreamExt API.
§Example
use tokio_stream::StreamExt;
use reqwest_sse::EventSource;
#[tokio::main]
async fn main() {
let mut events = reqwest::get("https://sse.test-free.online/api/story")
.await.unwrap()
.events()
.await.unwrap();
while let Some(Ok(event)) = events.next().await {
println!("{event:?}");
}
}Modules§
Structs§
- Event
- Server-Sent Event representation.
Statics§
Traits§
- Event
Source - A trait for consuming a
Responseas aStreamof Server-SentEvents (SSE).
Type Aliases§
- Server
Sent Events - Represents a stream of Server-Sent Events.