I am trying to write a filter in Spring Webflux, but am unable to find an option to apply the filter only to certain URL patterns. In the Spring MVC world, this can be achieved using
FilterRegistrationBean.addUrlPatterns("/protected/*");
But I am unable to find an equivalent for it in the webflux world.
As a workaround, I am using the following, but it obviously is not the right way to do it
String path = serverWebExchange.getRequest().getURI().getPath();
if(path.contains("/protected/"))
<do-something>
Is there any Spring Webflux native URL pattern matching method in WebFilterChain that I can use to apply the filter to only a specific set of URLs ? Thanks !