reqwest-eventsource

Crates.ioreqwest-eventsource
lib.rsreqwest-eventsource
version0.6.0
sourcesrc
created_at2020-06-28 15:25:01.534008
updated_at2024-03-29 15:28:36.624069
descriptionHelper to build an Eventsource using reqwest
homepagehttps://github.com/jpopesculian/reqwest-eventsource
repositoryhttps://github.com/jpopesculian/reqwest-eventsource
max_upload_size
id259126
size74,518
Julian Popescu (jpopesculian)

documentation

https://docs.rs/reqwest-eventsource/

README

reqwest-eventsource

Provides a simple wrapper for [reqwest] to provide an Event Source implementation. You can learn more about Server Sent Events (SSE) take a look at the MDN docs This crate uses [eventsource_stream] to wrap the underlying Bytes stream, and retries failed requests.

Example

let mut es = EventSource::get("http://localhost:8000/events");
while let Some(event) = es.next().await {
    match event {
        Ok(Event::Open) => println!("Connection Open!"),
        Ok(Event::Message(message)) => println!("Message: {:#?}", message),
        Err(err) => {
            println!("Error: {}", err);
            es.close();
        }
    }
}

License: MIT OR Apache-2.0

Commit count: 19

cargo fmt