Interface HandlerAdapter
- All Known Implementing Classes:
HandlerFunctionAdapter
,RequestMappingHandlerAdapter
,SimpleHandlerAdapter
,WebSocketHandlerAdapter
DispatcherHandler
from the details of
invoking a handler and makes it possible to support any handler type.
A HandlerAdapter
can implement DispatchExceptionHandler
if it wants to handle an exception that occurred before the request is mapped
to a handler. This allows the HandlerAdapter
to expose a consistent
exception handling mechanism for any request handling error.
In Reactive Streams terms, handle(org.springframework.web.server.ServerWebExchange, java.lang.Object)
processes the onNext, while
DispatchExceptionHandler.handleError(org.springframework.web.server.ServerWebExchange, java.lang.Throwable)
processes the onError signal
from the upstream.
- Since:
- 5.0
- Author:
- Rossen Stoyanchev, Sebastien Deleuze
-
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Mono<HandlerResult>
handle
(ServerWebExchange exchange, Object handler) Handle the request with the given handler.boolean
Whether thisHandlerAdapter
supports the givenhandler
.
-
Method Details
-
supports
Whether thisHandlerAdapter
supports the givenhandler
.- Parameters:
handler
- the handler object to check- Returns:
- whether the handler is supported
-
handle
Handle the request with the given handler.Implementations are encouraged to handle exceptions resulting from the invocation of a handler in order and if necessary to return an alternate result that represents an error response.
Furthermore since an async
HandlerResult
may produce an error later during result handling implementations are also encouraged toset an exception handler
on theHandlerResult
so that may also be applied later after result handling.- Parameters:
exchange
- current server exchangehandler
- the selected handler which must have been previously checked viasupports(Object)
- Returns:
Mono
that emits a singleHandlerResult
or none if the request has been fully handled and doesn't require further handling.
-