Sync docs from master to gh-pages

This commit is contained in:
buildmaster
2018-07-05 19:43:22 +00:00
parent e63a6940ec
commit 53b43e3d37
3 changed files with 107 additions and 3 deletions

View File

@@ -844,7 +844,45 @@ using something like <link xl:href="http://projects.spring.io/spring-session/">S
<simpara>The <literal>GlobalFilter</literal> interface has the same signature as <literal>GatewayFilter</literal>. These are special filters that are conditionally applied to all routes. (This interface and usage are subject to change in future milestones).</simpara>
<section xml:id="_combined_global_filter_and_gatewayfilter_ordering">
<title>Combined Global Filter and GatewayFilter Ordering</title>
<simpara>TODO: document ordering</simpara>
<simpara>When a request comes in (and matches a Route) the Filtering Web Handler will add all instances of <literal>GlobalFilter</literal> and all route specific instances of <literal>GatewayFilter</literal> to a filter chain. This combined filter chain is sorted by the <literal>org.springframework.core.Ordered</literal> interface, which can be set by implementing the <literal>getOrder()</literal> method or by using the <literal>@Order</literal> annotation.</simpara>
<simpara>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.</simpara>
<formalpara>
<title>ExampleConfiguration.java</title>
<para>
<programlisting language="java" linenumbering="unnumbered">@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");
}));
};
}
@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");
}));
};
}
@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");
}));
};
}</programlisting>
</para>
</formalpara>
</section>
<section xml:id="_forward_routing_filter">
<title>Forward Routing Filter</title>