Crates.io | reqwest-eventsource-wasi |
lib.rs | reqwest-eventsource-wasi |
version | 0.5.0 |
source | src |
created_at | 2023-11-15 02:58:32.173236 |
updated_at | 2023-11-15 02:58:32.173236 |
description | Helper to build an Eventsource using reqwest |
homepage | https://github.com/jpopesculian/reqwest-eventsource |
repository | https://github.com/jpopesculian/reqwest-eventsource |
max_upload_size | |
id | 1035885 |
size | 77,621 |
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.
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