Simple Server-Sent Events (SSE) library for hyper and Rocket using JSON for message encoding.
toml
[dependencies]
hyper-sse = "0.1"
lazy_static = "1"
```rust extern crate hyper_sse;
use hyper_sse::Server; use std::io::BufRead;
lazy_static! {
static ref SSE: Server
fn main() { SSE.spawn("[::1]:3000".parse().unwrap());
// Use SSE.generate_auth_token(_) to generate auth tokens
let stdin = std::io::stdin();
for line in stdin.lock().lines() {
let line = line.unwrap();
SSE.push(0, "update", &line).ok();
}
} ```
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.