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

fromPublisher

open static fun <T : Any, P : Publisher<T>> fromPublisher(publisher: P, elementClass: Class<T>): BodyInserter<P, ReactiveHttpOutputMessage>

Return a BodyInserter that writes the given Publisher.

Note also that org.springframework.web.reactive.function.client.WebClient and org.springframework.web.reactive.function.server.ServerResponse each offer body shortcut methods for providing a Publisher as the body.

Parameters

publisher - the publisher to stream to the response body

elementClass - the class of elements contained in the publisher

- the type of the elements contained in the publisher

- the type of the Publisher

Return
a BodyInserter that writes a Publisher

open static fun <T : Any, P : Publisher<T>> fromPublisher(publisher: P, typeReference: ParameterizedTypeReference<T>): BodyInserter<P, ReactiveHttpOutputMessage>

Return a BodyInserter that writes the given Publisher.

Note also that org.springframework.web.reactive.function.client.WebClient and org.springframework.web.reactive.function.server.ServerResponse each offer body shortcut methods for providing a Publisher as the body.

Parameters

publisher - the publisher to stream to the response body

typeReference - the type of elements contained in the publisher

- the type of the elements contained in the publisher

- the type of the Publisher

Return
a BodyInserter that writes a Publisher