public static interface ServerResponse.BodyBuilder extends ServerResponse.HeadersBuilder<ServerResponse.BodyBuilder>
| Modifier and Type | Method and Description |
|---|---|
reactor.core.publisher.Mono<ServerResponse> |
body(BodyInserter<?,? super ServerHttpResponse> inserter)
Set the body of the response to the given
BodyInserter and return it. |
reactor.core.publisher.Mono<ServerResponse> |
body(Object producer,
Class<?> elementClass)
Variant of
body(Publisher, Class) that allows using any
producer that can be resolved to Publisher via
ReactiveAdapterRegistry. |
reactor.core.publisher.Mono<ServerResponse> |
body(Object producer,
ParameterizedTypeReference<?> elementTypeRef)
Variant of
body(Publisher, ParameterizedTypeReference) that
allows using any producer that can be resolved to Publisher
via ReactiveAdapterRegistry. |
<T,P extends Publisher<T>> |
body(P publisher,
Class<T> elementClass)
Set the body from the given
Publisher. |
<T,P extends Publisher<T>> |
body(P publisher,
ParameterizedTypeReference<T> elementTypeRef)
Variant of
body(Publisher, Class) that allows using any
producer that can be resolved to Publisher via
ReactiveAdapterRegistry. |
reactor.core.publisher.Mono<ServerResponse> |
bodyValue(Object body)
Set the body of the response to the given
Object and return it. |
ServerResponse.BodyBuilder |
contentLength(long contentLength)
Set the length of the body in bytes, as specified by the
Content-Length header. |
ServerResponse.BodyBuilder |
contentType(MediaType contentType)
Set the media type of the body, as specified by the
Content-Type header. |
ServerResponse.BodyBuilder |
hint(String key,
Object value)
Add a serialization hint like
Jackson2CodecSupport.JSON_VIEW_HINT
to customize how the body will be serialized. |
ServerResponse.BodyBuilder |
hints(Consumer<Map<String,Object>> hintsConsumer)
Customize the serialization hints with the given consumer.
|
reactor.core.publisher.Mono<ServerResponse> |
render(String name,
Map<String,?> model)
Render the template with the given
name using the given model. |
reactor.core.publisher.Mono<ServerResponse> |
render(String name,
Object... modelAttributes)
Render the template with the given
name using the given modelAttributes. |
reactor.core.publisher.Mono<ServerResponse> |
syncBody(Object body)
Deprecated.
as of Spring Framework 5.2 in favor of
bodyValue(Object) |
allow, allow, build, build, build, cacheControl, cookie, cookies, eTag, header, headers, lastModified, lastModified, location, varyByServerResponse.BodyBuilder contentLength(long contentLength)
Content-Length header.contentLength - the content lengthHttpHeaders.setContentLength(long)ServerResponse.BodyBuilder contentType(MediaType contentType)
Content-Type header.contentType - the content typeHttpHeaders.setContentType(MediaType)ServerResponse.BodyBuilder hint(String key, Object value)
Jackson2CodecSupport.JSON_VIEW_HINT
to customize how the body will be serialized.key - the hint keyvalue - the hint valueServerResponse.BodyBuilder hints(Consumer<Map<String,Object>> hintsConsumer)
hintsConsumer - a function that consumes the hintsreactor.core.publisher.Mono<ServerResponse> bodyValue(Object body)
Object and return it.
This is a shortcut for using a body(BodyInserter) with a
value inserter.body - the body of the responseIllegalArgumentException - if body is a
Publisher or producer known to ReactiveAdapterRegistry<T,P extends Publisher<T>> reactor.core.publisher.Mono<ServerResponse> body(P publisher, Class<T> elementClass)
T - the type of the elements contained in the publisherP - the type of the Publisherpublisher - the Publisher to write to the responseelementClass - the type of elements published<T,P extends Publisher<T>> reactor.core.publisher.Mono<ServerResponse> body(P publisher, ParameterizedTypeReference<T> elementTypeRef)
body(Publisher, Class) that allows using any
producer that can be resolved to Publisher via
ReactiveAdapterRegistry.T - the type of the elements contained in the publisherP - the type of the Publisherpublisher - the Publisher to use to write the responseelementTypeRef - the type of elements producedreactor.core.publisher.Mono<ServerResponse> body(Object producer, Class<?> elementClass)
body(Publisher, Class) that allows using any
producer that can be resolved to Publisher via
ReactiveAdapterRegistry.producer - the producer to write to the requestelementClass - the type of elements producedreactor.core.publisher.Mono<ServerResponse> body(Object producer, ParameterizedTypeReference<?> elementTypeRef)
body(Publisher, ParameterizedTypeReference) that
allows using any producer that can be resolved to Publisher
via ReactiveAdapterRegistry.producer - the producer to write to the responseelementTypeRef - the type of elements producedreactor.core.publisher.Mono<ServerResponse> body(BodyInserter<?,? super ServerHttpResponse> inserter)
BodyInserter and return it.inserter - the BodyInserter that writes to the response@Deprecated reactor.core.publisher.Mono<ServerResponse> syncBody(Object body)
bodyValue(Object)Object and return it.
As of 5.2 this method delegates to bodyValue(Object).reactor.core.publisher.Mono<ServerResponse> render(String name, Object... modelAttributes)
name using the given modelAttributes.
The model attributes are mapped under a
generated name.
Note: Empty Collections are not added to
the model when using this method because we cannot correctly determine
the true convention name.
name - the name of the template to be renderedmodelAttributes - the modelAttributes used to render the templatereactor.core.publisher.Mono<ServerResponse> render(String name, Map<String,?> model)
name using the given model.name - the name of the template to be renderedmodel - the model used to render the template