Class ResponseBodyResultHandler
java.lang.Object
org.springframework.web.reactive.result.HandlerResultHandlerSupport
org.springframework.web.reactive.result.method.annotation.AbstractMessageWriterResultHandler
org.springframework.web.reactive.result.method.annotation.ResponseBodyResultHandler
- All Implemented Interfaces:
Ordered,HandlerResultHandler
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.
- Since:
- 5.0
- Author:
- Rossen Stoyanchev, Stephane Maldini, Sebastien Deleuze, Arjen Poutsma
-
Field Summary
Fields inherited from class org.springframework.web.reactive.result.method.annotation.AbstractMessageWriterResultHandler
COROUTINES_FLOW_CLASS_NAMEFields inherited from class org.springframework.web.reactive.result.HandlerResultHandlerSupport
loggerFields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
ConstructorsConstructorDescriptionResponseBodyResultHandler(List<HttpMessageWriter<?>> writers, RequestedContentTypeResolver resolver) Basic constructor with a defaultReactiveAdapterRegistry.ResponseBodyResultHandler(List<HttpMessageWriter<?>> writers, RequestedContentTypeResolver resolver, ReactiveAdapterRegistry registry) Constructor with anReactiveAdapterRegistryinstance. -
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Mono<Void>handleResult(ServerWebExchange exchange, HandlerResult result) Process the given result modifying response headers and/or writing data to the response.booleansupports(HandlerResult result) Whether this handler supports the givenHandlerResult.Methods inherited from class org.springframework.web.reactive.result.method.annotation.AbstractMessageWriterResultHandler
getMessageWriters, writeBody, writeBodyMethods inherited from class org.springframework.web.reactive.result.HandlerResultHandlerSupport
getAdapter, getAdapterRegistry, getContentTypeResolver, getOrder, selectMediaType, selectMediaType, setOrder
-
Constructor Details
-
ResponseBodyResultHandler
public ResponseBodyResultHandler(List<HttpMessageWriter<?>> writers, RequestedContentTypeResolver resolver) Basic constructor with a defaultReactiveAdapterRegistry.- Parameters:
writers- the writers for serializing to the response bodyresolver- to determine the requested content type
-
ResponseBodyResultHandler
public ResponseBodyResultHandler(List<HttpMessageWriter<?>> writers, RequestedContentTypeResolver resolver, ReactiveAdapterRegistry registry) Constructor with anReactiveAdapterRegistryinstance.- Parameters:
writers- the writers for serializing to the response bodyresolver- to determine the requested content typeregistry- for adaptation to reactive types
-
-
Method Details
-
supports
Description copied from interface:HandlerResultHandlerWhether this handler supports the givenHandlerResult.- Specified by:
supportsin interfaceHandlerResultHandler- Parameters:
result- the result object to check- Returns:
- whether this object can use the given result
-
handleResult
public reactor.core.publisher.Mono<Void> handleResult(ServerWebExchange exchange, HandlerResult result) Description copied from interface:HandlerResultHandlerProcess the given result modifying response headers and/or writing data to the response.- Specified by:
handleResultin interfaceHandlerResultHandler- Parameters:
exchange- current server exchangeresult- the result from the handling- Returns:
Mono<Void>to indicate when request handling is complete.
-