Class UrlHandlerFilter
java.lang.Object
org.springframework.web.filter.reactive.UrlHandlerFilter
- All Implemented Interfaces:
webFilter
webFilter that modifies the URL, and
then redirects or wraps the request to apply the change.
To create an instance, you can use the following:
UrlHandlerFilter filter = UrlHandlerFilter
.trailingSlashHandler("/path1/**").redirect(HttpStatus.PERMANENT_REDIRECT)
.trailingSlashHandler("/path2/**").mutateRequest()
.build();
This webFilter should be ordered ahead of security filters.
- Since:
- 6.2
- Author:
- Rossen Stoyanchev
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Mono<Void> filter(ServerwebExchange exchange, webFilterChain chain) Process the web request and (optionally) delegate to the nextwebFilterthrough the givenwebFilterChain.trailingSlashHandler(String... pathPatterns) Create a builder by adding a handler for URL's with a trailing slash.
-
Method Details
-
filter
Description copied from interface:webFilterProcess the web request and (optionally) delegate to the nextwebFilterthrough the givenwebFilterChain. -
trailingSlashHandler
public static UrlHandlerFilter.Builder.TrailingSlashSpec trailingSlashHandler(String... pathPatterns) Create a builder by adding a handler for URL's with a trailing slash.- Parameters:
pathPatterns- path patterns to map the handler to, e.g."/path/*","/path/**","/path/foo/".- Returns:
- a spec to configure the trailing slash handler with
- See Also:
-