6 releases (breaking)

0.6.0 Mar 29, 2024
0.5.0 Oct 4, 2023
0.4.0 Feb 21, 2022
0.3.0 Jan 11, 2022
0.1.0 Jun 28, 2020

#20 in HTTP client

Download history 16401/week @ 2024-09-07 16186/week @ 2024-09-14 17359/week @ 2024-09-21 16067/week @ 2024-09-28 15594/week @ 2024-10-05 14956/week @ 2024-10-12 17581/week @ 2024-10-19 18566/week @ 2024-10-26 18309/week @ 2024-11-02 18107/week @ 2024-11-09 18214/week @ 2024-11-16 18529/week @ 2024-11-23 20204/week @ 2024-11-30 19754/week @ 2024-12-07 20025/week @ 2024-12-14 10061/week @ 2024-12-21

72,944 downloads per month
Used in 177 crates (46 directly)

MIT/Apache

21KB
403 lines

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


lib.rs:

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();
        }
    }
}

Dependencies

~7–18MB
~243K SLoC