public class ResponseBodyResultHandler extends AbstractMessageWriterResultHandler implements HandlerResultHandler
HandlerResultHandler
that handles return values from methods annotated
with @ResponseBody
writing to the body of the request or response with
an HttpMessageWriter
.
By default the order for this result handler is set to 100. As it detects
the presence of @ResponseBody
it should be ordered after result
handlers that look for a specific return type. Note however that this handler
does recognize and explicitly ignores the ResponseEntity
return type.
COROUTINES_FLOW_CLASS_NAME
logger
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Constructor and Description |
---|
ResponseBodyResultHandler(List<HttpMessageWriter<?>> writers,
RequestedContentTypeResolver resolver)
Basic constructor with a default
ReactiveAdapterRegistry . |
ResponseBodyResultHandler(List<HttpMessageWriter<?>> writers,
RequestedContentTypeResolver resolver,
ReactiveAdapterRegistry registry)
Constructor with an
ReactiveAdapterRegistry instance. |
Modifier and Type | Method and Description |
---|---|
reactor.core.publisher.Mono<Void> |
handleResult(ServerWebExchange exchange,
HandlerResult result)
Process the given result modifying response headers and/or writing data
to the response.
|
boolean |
supports(HandlerResult result)
Whether this handler supports the given
HandlerResult . |
getMessageWriters, writeBody, writeBody
getAdapter, getAdapterRegistry, getContentTypeResolver, getOrder, selectMediaType, setOrder
public ResponseBodyResultHandler(List<HttpMessageWriter<?>> writers, RequestedContentTypeResolver resolver)
ReactiveAdapterRegistry
.writers
- the writers for serializing to the response bodyresolver
- to determine the requested content typepublic ResponseBodyResultHandler(List<HttpMessageWriter<?>> writers, RequestedContentTypeResolver resolver, ReactiveAdapterRegistry registry)
ReactiveAdapterRegistry
instance.writers
- the writers for serializing to the response bodyresolver
- to determine the requested content typeregistry
- for adaptation to reactive typespublic boolean supports(HandlerResult result)
HandlerResultHandler
HandlerResult
.supports
in interface HandlerResultHandler
result
- the result object to checkpublic reactor.core.publisher.Mono<Void> handleResult(ServerWebExchange exchange, HandlerResult result)
HandlerResultHandler
handleResult
in interface HandlerResultHandler
exchange
- current server exchangeresult
- the result from the handlingMono<Void>
to indicate when request handling is complete.