spring-framework / org.springframework.web.reactive.function / BodyInserters / fromServerSentEvents

fromServerSentEvents

open static fun <T : Any, S : Publisher<ServerSentEvent<T>>> fromServerSentEvents(eventsPublisher: S): BodyInserter<S, ServerHttpResponse>

Return a BodyInserter that writes the given ServerSentEvent publisher.

Note that a SSE BodyInserter can also be obtained by passing a stream of strings or POJOs (to be encoded as JSON) to #fromPublisher(Publisher, Class), and specifying a text/event-stream Content-Type.

Parameters

eventsPublisher - the ServerSentEvent publisher to write to the response body

- the type of the elements contained in the ServerSentEvent

Return
a BodyInserter that writes a ServerSentEvent publisher

See Also
<a href="https://www.w3.org/TR/eventsource/">Server-Sent Events W3C recommendation</a>