1 unstable release
Uses new Rust 2024
| 0.1.0 | Jul 24, 2025 |
|---|
#903 in HTTP server
38 downloads per month
19KB
380 lines
Actix SSE
SSE implementation for Actix, extracted from actix-web-lab with minimal dependencies.
use std::{convert::Infallible, time::Duration};
#[get("/from-stream")]
async fn from_stream() -> impl Responder {
let event_stream = futures_util::stream::iter([Ok::<_, Infallible>(actix_sse::Event::Data(
actix_sse::Data::new("foo"),
))]);
actix_sse::Sse::from_stream(event_stream).with_keep_alive(Duration::from_secs(5))
}
Migrating from actix-web-lab
This should mostly be a drop-in replacement for the sse module, but we did remove a few convenience methods.
Data::from_json: Serialize in the caller and useData::newData::set_id: UseData::idSse::from_receiver: UseSse::from_stream(tokio_stream::wrappers::ReceiverStream::new(rx))
Dependencies
~15–30MB
~459K SLoC