1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
//! Async Server Sent Event parser and encoder. //! //! # Example //! //! ```norun //! use tide::Request; //! //! #[async_std::main] //! async fn main() -> http_types::Result<()> { //! let mut app = tide::new(); //! //! app.at("/sse").get(|req| async move { //! let mut res = tide_compressed_sse::upgrade(req, |_req: Request<()>, sender| async move { //! sender.send("message", "foo", None).await?; //! //! Ok(()) //! }); //! //! Ok(res) //! }); //! //! app.listen("localhost:8080").await?; //! //! Ok(()) //! } //! ``` //! //! # References //! //! - [SSE Spec](https://html.spec.whatwg.org/multipage/server-sent-events.html#concept-event-stream-last-event-id) //! - [EventSource web platform tests](https://github.com/web-platform-tests/wpt/tree/master/eventsource) #![deny(missing_debug_implementations, nonstandard_style)] #![warn(missing_docs, rust_2018_idioms)] mod decoder; mod encoder; mod event; mod handshake; mod lines; mod message; mod tide; use encoder::encode; use event::Event; use message::Message; pub use crate::tide::upgrade::upgrade; pub use crate::tide::Sender; /// Exports for tests #[cfg(feature = "__internal_test")] pub mod internals { pub use crate::decoder::{decode, Decoder}; pub use crate::encoder::{encode, Encoder}; pub use crate::event::Event; } pub(crate) use lines::Lines;