reqwest-sse 0.2.0

Lightweight SSE client over reqwest
Documentation

reqwest-sse

Made With Rust Crates.io Docs.rs

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://example.com/sse")
        .await.unwrap()
        .events()
        .await.unwrap();

    while let Some(Ok(event)) = events.next().await {
        println!("{event:?}");
    }
}