public abstract class BodyInserters extends Object
BodyInserter
that write various bodies, such a reactive streams,
server-sent events, resources, etc.Constructor and Description |
---|
BodyInserters() |
Modifier and Type | Method and Description |
---|---|
static <T> BodyInserter<T> |
fromObject(T body)
Return a
BodyInserter that writes the given single object. |
static <S extends org.reactivestreams.Publisher<T>,T> |
fromPublisher(S publisher,
Class<T> elementClass)
Return a
BodyInserter that writes the given Publisher . |
static <S extends org.reactivestreams.Publisher<T>,T> |
fromPublisher(S publisher,
org.springframework.core.ResolvableType elementType)
Return a
BodyInserter that writes the given Publisher . |
static <T extends org.springframework.core.io.Resource> |
fromResource(T resource)
Return a
BodyInserter that writes the given Resource . |
static <T,S extends org.reactivestreams.Publisher<org.springframework.http.codec.ServerSentEvent<T>>> |
fromServerSentEvents(S eventsPublisher)
Return a
BodyInserter that writes the given ServerSentEvent publisher. |
static <T,S extends org.reactivestreams.Publisher<T>> |
fromServerSentEvents(S eventsPublisher,
Class<T> eventClass)
Return a
BodyInserter that writes the given Publisher publisher as
Server-Sent Events. |
static <T,S extends org.reactivestreams.Publisher<T>> |
fromServerSentEvents(S eventsPublisher,
org.springframework.core.ResolvableType eventType)
Return a
BodyInserter that writes the given Publisher publisher as
Server-Sent Events. |
public static <T> BodyInserter<T> fromObject(T body)
BodyInserter
that writes the given single object.body
- the body of the responseBodyInserter
that writes a single objectpublic static <S extends org.reactivestreams.Publisher<T>,T> BodyInserter<S> fromPublisher(S publisher, Class<T> elementClass)
BodyInserter
that writes the given Publisher
.T
- the type of the elements contained in the publisherS
- the type of the Publisher
.publisher
- the publisher to stream to the response bodyelementClass
- the class of elements contained in the publisherBodyInserter
that writes a Publisher
public static <S extends org.reactivestreams.Publisher<T>,T> BodyInserter<S> fromPublisher(S publisher, org.springframework.core.ResolvableType elementType)
BodyInserter
that writes the given Publisher
.T
- the type of the elements contained in the publisherS
- the type of the Publisher
.publisher
- the publisher to stream to the response bodyelementType
- the type of elements contained in the publisherBodyInserter
that writes a Publisher
public static <T extends org.springframework.core.io.Resource> BodyInserter<T> fromResource(T resource)
BodyInserter
that writes the given Resource
.
If the resource can be resolved to a file, it will be copied
using
zero-copyT
- the type of the Resource
resource
- the resource to write to the responseBodyInserter
that writes a Publisher
public static <T,S extends org.reactivestreams.Publisher<org.springframework.http.codec.ServerSentEvent<T>>> BodyInserter<S> fromServerSentEvents(S eventsPublisher)
BodyInserter
that writes the given ServerSentEvent
publisher.T
- the type of the elements contained in the ServerSentEvent
eventsPublisher
- the ServerSentEvent
publisher to write to the response bodyBodyInserter
that writes a ServerSentEvent
publisherpublic static <T,S extends org.reactivestreams.Publisher<T>> BodyInserter<S> fromServerSentEvents(S eventsPublisher, Class<T> eventClass)
BodyInserter
that writes the given Publisher
publisher as
Server-Sent Events.T
- the type of the elements contained in the publishereventsPublisher
- the publisher to write to the response body as Server-Sent EventseventClass
- the class of event contained in the publisherBodyInserter
that writes the given Publisher
publisher as
Server-Sent Eventspublic static <T,S extends org.reactivestreams.Publisher<T>> BodyInserter<S> fromServerSentEvents(S eventsPublisher, org.springframework.core.ResolvableType eventType)
BodyInserter
that writes the given Publisher
publisher as
Server-Sent Events.T
- the type of the elements contained in the publishereventsPublisher
- the publisher to write to the response body as Server-Sent EventseventType
- the type of event contained in the publisherBodyInserter
that writes the given Publisher
publisher as
Server-Sent Events