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

#17 in HTTP client

Download history 15549/week @ 2024-08-22 15821/week @ 2024-08-29 16602/week @ 2024-09-05 17889/week @ 2024-09-12 16181/week @ 2024-09-19 16593/week @ 2024-09-26 16007/week @ 2024-10-03 13993/week @ 2024-10-10 17758/week @ 2024-10-17 17939/week @ 2024-10-24 18469/week @ 2024-10-31 18145/week @ 2024-11-07 17864/week @ 2024-11-14 19114/week @ 2024-11-21 18947/week @ 2024-11-28 16862/week @ 2024-12-05

76,043 downloads per month
Used in 172 crates (44 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

~5–16MB
~210K SLoC