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
-
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Mono<Void>
filter
(ServerWebExchange exchange, WebFilterChain chain) Process the Web request and (optionally) delegate to the nextWebFilter
through 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:WebFilter
Process the Web request and (optionally) delegate to the nextWebFilter
through 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:
-