axum/src
David Pedersen 6d787665d6
Server-Sent Events (#75)
Example usage:

```rust
use axum::{prelude::*, sse::{sse, Event, KeepAlive}};
use tokio_stream::StreamExt as _;
use futures::stream::{self, Stream};
use std::{
    time::Duration,
    convert::Infallible,
};

let app = route("/sse", sse(make_stream).keep_alive(KeepAlive::default()));

async fn make_stream(
    // you can also put extractors here
) -> Result<impl Stream<Item = Result<Event, Infallible>>, Infallible> {
    // A `Stream` that repeats an event every second
    let stream = stream::repeat_with(|| Event::default().data("hi!"))
        .map(Ok)
        .throttle(Duration::from_secs(1));

    Ok(stream)
}
```

Implementation is based on [warp's](https://github.com/seanmonstar/warp/blob/master/src/filters/sse.rs)
2021-08-01 21:49:17 +02:00
..
extract Improve error message of MissingExtension rejections (#72) 2021-08-01 15:50:57 +02:00
handler Return 405 Method Not Allowed for unsupported method for route (#63) 2021-07-31 21:05:53 +02:00
service Fix typos in service docs (#74) 2021-08-01 20:55:09 +02:00
ws Fix websockets failing on Firefox (#76) 2021-08-01 21:00:38 +02:00
body.rs Clarify required response body type when routing to tower::Services (#69) 2021-08-01 15:42:12 +02:00
buffer.rs Rename to axum (#28) 2021-07-09 21:36:14 +02:00
lib.rs Server-Sent Events (#75) 2021-08-01 21:49:17 +02:00
macros.rs Add Multipart extractor for consuming multipart/form-data requests (#32) 2021-07-14 16:53:37 +02:00
response.rs Implement IntoResponse for Body 2021-07-22 21:22:46 +02:00
routing.rs Add extractor for remote connection info (#55) 2021-07-31 21:36:30 +02:00
sse.rs Server-Sent Events (#75) 2021-08-01 21:49:17 +02:00
tests.rs Return 405 Method Not Allowed for unsupported method for route (#63) 2021-07-31 21:05:53 +02:00
util.rs Replace unsafe with unwrap (#20) 2021-06-15 23:18:49 +02:00