Skip to main content

sse_response

Function sse_response 

Source
pub fn sse_response<S>(stream: S) -> Response
where S: Stream<Item = SseEvent> + Send + Unpin + 'static,
Expand description

Convenience function to create an SSE response from an iterator.

§Example

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

let events = vec![
    SseEvent::message("Hello"),
    SseEvent::message("World"),
];

let response = sse_response(asupersync::stream::iter(events));