Explicitly configure and document WebFilter orderings
Closes gh-11756
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,6 +23,8 @@ import io.micrometer.core.instrument.Tag;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
import org.springframework.web.server.WebFilter;
|
||||
import org.springframework.web.server.WebFilterChain;
|
||||
@@ -34,6 +36,7 @@ import org.springframework.web.server.WebFilterChain;
|
||||
* @author Jon Schneider
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@Order(Ordered.HIGHEST_PRECEDENCE + 1)
|
||||
public class MetricsWebFilter implements WebFilter {
|
||||
|
||||
private final MeterRegistry registry;
|
||||
|
||||
@@ -2641,6 +2641,29 @@ follows:
|
||||
|
||||
|
||||
|
||||
[[boot-features-webflux-web-filters]]
|
||||
==== Web Filters
|
||||
Spring WebFlux provides a `WebFilter` interface that can be implemented to filter HTTP
|
||||
request-response exchanges. `WebFilter` beans found in the application context will
|
||||
be automatically used to filter each exchange.
|
||||
|
||||
Where the order of the filters is important they can implemented `Ordered` or be annotated
|
||||
with `@Order`. Spring Boot auto-configuration may configure web filters for you. When it
|
||||
does so, the orders shown in the following table will be used:
|
||||
|
||||
|===
|
||||
| Web Filter | Order
|
||||
|
||||
|`MetricsWebFilter`
|
||||
|`Ordered.HIGHEST_PRECEDENCE + 1`
|
||||
|
||||
|`WebFilterChainProxy` (Spring Security)
|
||||
|`-100`
|
||||
|
||||
|===
|
||||
|
||||
|
||||
|
||||
[[boot-features-jersey]]
|
||||
=== JAX-RS and Jersey
|
||||
If you prefer the JAX-RS programming model for REST endpoints, you can use one of the
|
||||
|
||||
Reference in New Issue
Block a user