Reputation: 2347
With spring webflux and the @RestController
model, I have a @RestControllerAdvice
with some @ExceptionHandler
methods.
I would like to get the original request as parameter because I want to log it and use it in my response.
However I have tried all the possible types for an handler method in the classic MVC model but none of them was accepted (HttpServletRequest
, WebRequest
and ServerRequest
).
What type can I use to access the original request in a webflux annotated handler method ?
Upvotes: 12
Views: 8300
Reputation: 59086
You should use org.springframework.http.server.reactive.ServerHttpRequest
, because:
HttpServletRequest
and WebRequest
are Servlet/Spring MVC specificServerRequest
belongs to Spring WebFlux, but the functional variantUpvotes: 25