sse_response

Function sse_response 

Source
pub fn sse_response<I>(events: I) -> Response<Full<Bytes>>
where I: IntoIterator<Item = SseEvent>,
Expand description

Create an SSE response from a synchronous iterator of events

This is a convenience function for simple cases with pre-computed events.

§Example

use rustapi_core::sse::{sse_response, SseEvent};

async fn handler() -> Response {
    sse_response(vec![
        SseEvent::new("Hello"),
        SseEvent::new("World").event("greeting"),
    ])
}