Sync docs from master to gh-pages

This commit is contained in:
buildmaster
2019-10-15 14:59:20 +00:00
parent ff386b0047
commit 12addadbfe
2 changed files with 30 additions and 58 deletions

View File

@@ -1933,45 +1933,31 @@ This property takes a list of filters</p>
<div class="sect2">
<h3 id="combined-global-filter-and-gatewayfilter-ordering"><a class="anchor" href="#combined-global-filter-and-gatewayfilter-ordering"></a><a class="link" href="#combined-global-filter-and-gatewayfilter-ordering">6.1. Combined Global Filter and GatewayFilter Ordering</a></h3>
<div class="paragraph">
<p>When a request comes in (and matches a Route) the Filtering Web Handler will add all instances of <code>GlobalFilter</code> and all route specific instances of <code>GatewayFilter</code> to a filter chain. This combined filter chain is sorted by the <code>org.springframework.core.Ordered</code> interface, which can be set by implementing the <code>getOrder()</code> method or by using the <code>@Order</code> annotation.</p>
<p>When a request comes in (and matches a Route) the Filtering Web Handler will add all instances of <code>GlobalFilter</code> and all route specific instances of <code>GatewayFilter</code> to a filter chain. This combined filter chain is sorted by the <code>org.springframework.core.Ordered</code> interface, which can be set by implementing the <code>getOrder()</code> method.</p>
</div>
<div class="paragraph">
<p>As Spring Cloud Gateway distinguishes between "pre" and "post" phases for filter logic execution (see: How It Works), the filter with the highest precedence will be the first in the "pre"-phase and the last in the "post"-phase.</p>
<p>As Spring Cloud Gateway distinguishes between "pre" and "post" phases for filter logic execution (see: <a href="#gateway-how-it-works">How it Works</a>), the filter with the highest precedence will be the first in the "pre"-phase and the last in the "post"-phase.</p>
</div>
<div class="listingblock">
<div class="title">ExampleConfiguration.java</div>
<div class="content">
<pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">@Bean
@Order(-1)
public GlobalFilter a() {
return (exchange, chain) -&gt; {
log.info("first pre filter");
return chain.filter(exchange).then(Mono.fromRunnable(() -&gt; {
log.info("third post filter");
}));
};
public GlobalFilter customFilter() {
return CustomGlobalFilter();
}
@Bean
@Order(0)
public GlobalFilter b() {
return (exchange, chain) -&gt; {
log.info("second pre filter");
return chain.filter(exchange).then(Mono.fromRunnable(() -&gt; {
log.info("second post filter");
}));
};
}
public class CustomGlobalFilter implements GlobalFilter, Ordered {
@Bean
@Order(1)
public GlobalFilter c() {
return (exchange, chain) -&gt; {
log.info("third pre filter");
return chain.filter(exchange).then(Mono.fromRunnable(() -&gt; {
log.info("first post filter");
}));
};
@Override
public Mono&lt;Void&gt; filter(ServerWebExchange exchange, GatewayFilterChain chain) {
log.info("custom global filter");
return chain.filter(exchange);
}
@Override
public int getOrder() {
return -1;
}
}</code></pre>
</div>
</div>

View File

@@ -1933,45 +1933,31 @@ This property takes a list of filters</p>
<div class="sect2">
<h3 id="combined-global-filter-and-gatewayfilter-ordering"><a class="anchor" href="#combined-global-filter-and-gatewayfilter-ordering"></a><a class="link" href="#combined-global-filter-and-gatewayfilter-ordering">6.1. Combined Global Filter and GatewayFilter Ordering</a></h3>
<div class="paragraph">
<p>When a request comes in (and matches a Route) the Filtering Web Handler will add all instances of <code>GlobalFilter</code> and all route specific instances of <code>GatewayFilter</code> to a filter chain. This combined filter chain is sorted by the <code>org.springframework.core.Ordered</code> interface, which can be set by implementing the <code>getOrder()</code> method or by using the <code>@Order</code> annotation.</p>
<p>When a request comes in (and matches a Route) the Filtering Web Handler will add all instances of <code>GlobalFilter</code> and all route specific instances of <code>GatewayFilter</code> to a filter chain. This combined filter chain is sorted by the <code>org.springframework.core.Ordered</code> interface, which can be set by implementing the <code>getOrder()</code> method.</p>
</div>
<div class="paragraph">
<p>As Spring Cloud Gateway distinguishes between "pre" and "post" phases for filter logic execution (see: How It Works), the filter with the highest precedence will be the first in the "pre"-phase and the last in the "post"-phase.</p>
<p>As Spring Cloud Gateway distinguishes between "pre" and "post" phases for filter logic execution (see: <a href="#gateway-how-it-works">How it Works</a>), the filter with the highest precedence will be the first in the "pre"-phase and the last in the "post"-phase.</p>
</div>
<div class="listingblock">
<div class="title">ExampleConfiguration.java</div>
<div class="content">
<pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">@Bean
@Order(-1)
public GlobalFilter a() {
return (exchange, chain) -&gt; {
log.info("first pre filter");
return chain.filter(exchange).then(Mono.fromRunnable(() -&gt; {
log.info("third post filter");
}));
};
public GlobalFilter customFilter() {
return CustomGlobalFilter();
}
@Bean
@Order(0)
public GlobalFilter b() {
return (exchange, chain) -&gt; {
log.info("second pre filter");
return chain.filter(exchange).then(Mono.fromRunnable(() -&gt; {
log.info("second post filter");
}));
};
}
public class CustomGlobalFilter implements GlobalFilter, Ordered {
@Bean
@Order(1)
public GlobalFilter c() {
return (exchange, chain) -&gt; {
log.info("third pre filter");
return chain.filter(exchange).then(Mono.fromRunnable(() -&gt; {
log.info("first post filter");
}));
};
@Override
public Mono&lt;Void&gt; filter(ServerWebExchange exchange, GatewayFilterChain chain) {
log.info("custom global filter");
return chain.filter(exchange);
}
@Override
public int getOrder() {
return -1;
}
}</code></pre>
</div>
</div>