hyper-sse

Crates.iohyper-sse
lib.rshyper-sse
version0.1.0
sourcesrc
created_at2018-07-08 23:14:33.240108
updated_at2018-07-08 23:14:33.240108
descriptionServer-Sent Events (SSE) library for hyper and Rocket
homepage
repositoryhttps://github.com/klemens/hyper-sse
max_upload_size
id73416
size16,905
Klemens Schölhorn (klemens)

documentation

https://docs.rs/hyper-sse

README

hyper-sse

crates.io version docs.rs version

Simple Server-Sent Events (SSE) library for hyper and Rocket using JSON for message encoding.

Example

[dependencies]
hyper-sse = "0.1"
lazy_static = "1"
extern crate hyper_sse;
#[macro_use] extern crate lazy_static;

use hyper_sse::Server;
use std::io::BufRead;

lazy_static! {
    static ref SSE: Server<u8> = Server::new();
}

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

License

Licensed under either of

at your option.

Contribution

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.

Commit count: 30

cargo fmt