-
Notifications
You must be signed in to change notification settings - Fork 38.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide RequestPredicate
with no side effects
#25814
Comments
RequestPredicate
with no side effects.RequestPredicate
with no side effects
I don't understand which part is the caveat. It gives you choice, so you can use what you need.
WebFlux uses |
Thank you for your reply. I am not a native speaker, so please ask for details if you have difficulty understanding.
In my case, there are relatively large files such as font files and Javascript frameworks in static resources. On the other hand, I had to exclude some I am aware that Caching controls using
This is my problem, but after creating my own matcher, I noticed that the URIs don't match.
That's right. However, in order to do URI matching with While digging through the source code and test code to find out how to use the After finding a helpful implementation, I quickly achieved my goal. I opened this issue to see if this could be provided as part of the Spring Framework to make it easier for users to use. This request may be a niche one. Regards, all of our contributors. |
I've found that my goal can be achieved without custom Since the only file that needs to be excluded from the cache is the @rstoyanchev Thank you for your kindness. |
I'm sorry. The specs clearly stated that the spring-framework/spring-web/src/main/java/org/springframework/web/util/pattern/PathPattern.java Lines 50 to 52 in 69921b4
I still need the custom Reopen this issue, but close the issue once you have determined that you do not need to provide this feature in Spring Framework. |
Indeed there may be room for improvement. The syntax for For the time being as a workaround you could put HTML files under a common base path, e.g. Now if we could come up with some syntax that would allow to express the above without necessarily going back to allowing "**" anywhere in the middle of a pattern. |
I'm developing a Spring WebFlux application that serve Single Page Application front-end resources.
I have registered front-end resources in the
ResourceHandlerRegistry
for distribution, but some of them have had to change theCache-Control
header.The
ResourceHandlerRegistry
cannot dynamically set the response headers according to the request URL or file extension.I figured this goal could be accomplished with the
WebFilter
as well as the Servet API.I used
WebFilter
in WebFlux to check the HTTP request and tried to change the HTTP header of the response, but theI've noticed that WebFlux has different caveats than the Servlet API.
e.g, when I was getting a path from
ServerHttpRequest
, I had to callrequest.getPath().pathWithinApplication()
or else the context path would be included.Spring MVC provided an
AntMatcher
, so I looked for Spring WebFlux to provide a useful matcher as well, so I found theRequestPredicate
, but this is a class for theRouterFunction
and seems to have some side effects.e.g,
RequestPredicates#path(String)
rewrites the path variable in the request.I then discovered that Spring Security had a ServerWebExchangeMatchers with no side effects, and I implemented my own matcher based on its implementation.
But this is reinventing the wheel.
I was referring to the Spring Security implementation in this case, but I think it would be a time saver for someone like me who wants to do conditional processing with
WebFilter
, if a similar feature was provided as part of Spring WebFlux.The following code is a sample of my
WebFilter
implementation.my.application.matcher.ServerWebExchangeMatcher
is a matcher based on Spring Security ServerWebExchangeMatchers.The text was updated successfully, but these errors were encountered: