Add SSE tests (#652)

* Add SSE tests

* Simplify keep alive test a bit

* More robust keep-alive tests

* rename a bit
This commit is contained in:
David Pedersen
2022-01-03 18:48:50 +01:00
committed by GitHub
parent 86331613f4
commit 6d24a8695f
4 changed files with 178 additions and 9 deletions
+6 -2
View File
@@ -56,7 +56,11 @@ async fn sse_handler(
// A `Stream` that repeats an event every second
let stream = stream::repeat_with(|| Event::default().data("hi!"))
.map(Ok)
.throttle(Duration::from_secs(1));
.throttle(Duration::from_secs(10));
Sse::new(stream)
Sse::new(stream).keep_alive(
axum::response::sse::KeepAlive::new()
.interval(Duration::from_secs(1))
.text("keep-alive-text"),
)
}