How to get requests path with unresolved variables in Spring WebFlux

387 Views Asked by At

I'm trying to get the request's path with unresolved path variables in a WebFilter. I know in SpringBoot Servlet version it is possible to do this by getting request's attribute with key org.springframework.web.servlet.View.pathVariables. Although it seems no attribute is populated in WebFlux regarding that. Is there anyway to do this in a filter?

1

There are 1 best solutions below

0
On

WebFlux version of org.springframework.web.servlet.View.pathVariables is org.springframework.web.reactive.HandlerMapping.bestMatchingPattern.

We can obtain it by doing

exchange.attributes[HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE]