'How to get requests path with unresolved variables in Spring WebFlux
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?
Solution 1:[1]
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]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | chriptus13 |