Sync docs from 2.0.x to gh-pages

This commit is contained in:
buildmaster
2017-11-16 17:24:27 +00:00
parent c2c6276819
commit b39068669c
3 changed files with 33 additions and 15 deletions

View File

@@ -20,21 +20,27 @@
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> uri</span>: http://example.org
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> filters</span>:
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> - SetStatus</span>=<span class="hl-number">401</span></pre><p>
</p><p>For some usages of the gateway, properties will be adequate, but some production use cases will benefit from loading configuration from an external source, such as a database. Future milestone versions will have <code class="literal">RouteDefinitionLocator</code> implementations based off of Spring Data Repositories such as: Redis, MongoDB and Cassandra.</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_fluent_java_routes_api" href="#_fluent_java_routes_api"></a>7.1&nbsp;Fluent Java Routes API</h2></div></div></div><p>To allow for simple configuration in Java, there is a fluent API defined in the <code class="literal">Routes</code> class.</p><p><b>Config.java.&nbsp;</b>
</p><p>For some usages of the gateway, properties will be adequate, but some production use cases will benefit from loading configuration from an external source, such as a database. Future milestone versions will have <code class="literal">RouteDefinitionLocator</code> implementations based off of Spring Data Repositories such as: Redis, MongoDB and Cassandra.</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_fluent_java_routes_api" href="#_fluent_java_routes_api"></a>7.1&nbsp;Fluent Java Routes API</h2></div></div></div><p>To allow for simple configuration in Java, there is a fluent API defined in the <code class="literal">Routes</code> class.</p><p><b>GatewaySampleApplication.java.&nbsp;</b>
</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// static imports from GatewayFilters and RoutePredicates</span>
<em><span class="hl-annotation" style="color: gray">@Bean</span></em>
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">public</span> RouteLocator customRouteLocator(ThrottleGatewayFilterFactory throttle) {
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">return</span> Routes.locator()
.route(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"test"</span>)
.uri(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"http://httpbin.org:80"</span>)
.predicate(host(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"**.abc.org"</span>).and(path(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"/image/png"</span>)))
.addResponseHeader(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"X-TestHeader"</span>, <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"foobar"</span>)
.and()
.route(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"test2"</span>)
.uri(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"http://httpbin.org:80"</span>)
.route(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"test2"</span>)
.predicate(path(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"/image/webp"</span>))
.add(addResponseHeader(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"X-AnotherHeader"</span>, <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"baz"</span>))
.and()
.uri(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"http://httpbin.org:80"</span>)
.route(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"test3"</span>)
.order(-<span class="hl-number">1</span>)
.predicate(host(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"**.throttle.org"</span>).and(path(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"/get"</span>)))
.add(throttle.apply(tuple().of(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"capacity"</span>, <span class="hl-number">1</span>,
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"refillTokens"</span>, <span class="hl-number">1</span>,
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"refillPeriod"</span>, <span class="hl-number">10</span>,
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"refillUnit"</span>, <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"SECONDS"</span>)))
.uri(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"http://httpbin.org:80"</span>)
.build();
}</pre><p>
</p><p>This style also allows for more custom predicate assertions. The predicates defined by <code class="literal">RouteDefinitionLocator</code> beans are combined using logical <code class="literal">and</code>. By using the fluent Java API, you can use the <code class="literal">and()</code>, <code class="literal">or()</code> and <code class="literal">negate()</code> operators on the <code class="literal">Predicate</code> class.</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__global_filters.html">Prev</a>&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;<a accesskey="n" href="multi__actuator_api.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">6.&nbsp;Global Filters&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud-gateway.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;8.&nbsp;Actuator API</td></tr></table></div></body></html>

View File

@@ -278,21 +278,27 @@ KeyResolver userKeyResolver() {
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> uri</span>: http://example.org
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> filters</span>:
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> - SetStatus</span>=<span class="hl-number">401</span></pre><p>
</p><p>For some usages of the gateway, properties will be adequate, but some production use cases will benefit from loading configuration from an external source, such as a database. Future milestone versions will have <code class="literal">RouteDefinitionLocator</code> implementations based off of Spring Data Repositories such as: Redis, MongoDB and Cassandra.</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_fluent_java_routes_api" href="#_fluent_java_routes_api"></a>7.1&nbsp;Fluent Java Routes API</h2></div></div></div><p>To allow for simple configuration in Java, there is a fluent API defined in the <code class="literal">Routes</code> class.</p><p><b>Config.java.&nbsp;</b>
</p><p>For some usages of the gateway, properties will be adequate, but some production use cases will benefit from loading configuration from an external source, such as a database. Future milestone versions will have <code class="literal">RouteDefinitionLocator</code> implementations based off of Spring Data Repositories such as: Redis, MongoDB and Cassandra.</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_fluent_java_routes_api" href="#_fluent_java_routes_api"></a>7.1&nbsp;Fluent Java Routes API</h2></div></div></div><p>To allow for simple configuration in Java, there is a fluent API defined in the <code class="literal">Routes</code> class.</p><p><b>GatewaySampleApplication.java.&nbsp;</b>
</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// static imports from GatewayFilters and RoutePredicates</span>
<em><span class="hl-annotation" style="color: gray">@Bean</span></em>
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">public</span> RouteLocator customRouteLocator(ThrottleGatewayFilterFactory throttle) {
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">return</span> Routes.locator()
.route(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"test"</span>)
.uri(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"http://httpbin.org:80"</span>)
.predicate(host(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"**.abc.org"</span>).and(path(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"/image/png"</span>)))
.addResponseHeader(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"X-TestHeader"</span>, <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"foobar"</span>)
.and()
.route(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"test2"</span>)
.uri(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"http://httpbin.org:80"</span>)
.route(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"test2"</span>)
.predicate(path(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"/image/webp"</span>))
.add(addResponseHeader(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"X-AnotherHeader"</span>, <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"baz"</span>))
.and()
.uri(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"http://httpbin.org:80"</span>)
.route(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"test3"</span>)
.order(-<span class="hl-number">1</span>)
.predicate(host(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"**.throttle.org"</span>).and(path(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"/get"</span>)))
.add(throttle.apply(tuple().of(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"capacity"</span>, <span class="hl-number">1</span>,
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"refillTokens"</span>, <span class="hl-number">1</span>,
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"refillPeriod"</span>, <span class="hl-number">10</span>,
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"refillUnit"</span>, <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"SECONDS"</span>)))
.uri(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"http://httpbin.org:80"</span>)
.build();
}</pre><p>
</p><p>This style also allows for more custom predicate assertions. The predicates defined by <code class="literal">RouteDefinitionLocator</code> beans are combined using logical <code class="literal">and</code>. By using the fluent Java API, you can use the <code class="literal">and()</code>, <code class="literal">or()</code> and <code class="literal">negate()</code> operators on the <code class="literal">Predicate</code> class.</p></div></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="_actuator_api" href="#_actuator_api"></a>8.&nbsp;Actuator API</h1></div></div></div><p>TODO: document the <code class="literal">/gateway</code> actuator endpoint</p></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="_developer_guide" href="#_developer_guide"></a>9.&nbsp;Developer Guide</h1></div></div></div><p>TODO: overview of writing custom integrations</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_writing_custom_route_predicate_factories" href="#_writing_custom_route_predicate_factories"></a>9.1&nbsp;Writing Custom Route Predicate Factories</h2></div></div></div><p>TODO: document writing Custom Route Predicate Factories</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_writing_custom_gatewayfilter_factories" href="#_writing_custom_gatewayfilter_factories"></a>9.2&nbsp;Writing Custom GatewayFilter Factories</h2></div></div></div><p>TODO: document writing Custom GatewayFilter Factories</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_writing_custom_global_filters" href="#_writing_custom_global_filters"></a>9.3&nbsp;Writing Custom Global Filters</h2></div></div></div><p>TODO: document writing Custom Global Filters</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_writing_custom_route_locators_and_writers" href="#_writing_custom_route_locators_and_writers"></a>9.4&nbsp;Writing Custom Route Locators and Writers</h2></div></div></div><p>TODO: document writing Custom Route Locators and Writers</p></div></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="_building_a_simple_gateway_using_spring_mvc" href="#_building_a_simple_gateway_using_spring_mvc"></a>10.&nbsp;Building a Simple Gateway Using Spring MVC</h1></div></div></div><p>Spring Cloud Gateway provides a utility object called <code class="literal">ProxyExchange</code> which you can use inside a regular Spring MVC handler as a method parameter. It supports basic downstream HTTP exchanges via methods that mirror the HTTP verbs, or forwarding to a local handler via the <code class="literal">forward()</code> method.</p><p>Example (proxying a request to "/test" downstream to a remote server):</p><pre class="programlisting"><em><span class="hl-annotation" style="color: gray">@RestController</span></em>

View File

@@ -695,22 +695,28 @@ KeyResolver userKeyResolver() {
<title>Fluent Java Routes API</title>
<simpara>To allow for simple configuration in Java, there is a fluent API defined in the <literal>Routes</literal> class.</simpara>
<formalpara>
<title>Config.java</title>
<title>GatewaySampleApplication.java</title>
<para>
<programlisting language="java" linenumbering="unnumbered">// static imports from GatewayFilters and RoutePredicates
@Bean
public RouteLocator customRouteLocator(ThrottleGatewayFilterFactory throttle) {
return Routes.locator()
.route("test")
.uri("http://httpbin.org:80")
.predicate(host("**.abc.org").and(path("/image/png")))
.addResponseHeader("X-TestHeader", "foobar")
.and()
.route("test2")
.uri("http://httpbin.org:80")
.route("test2")
.predicate(path("/image/webp"))
.add(addResponseHeader("X-AnotherHeader", "baz"))
.and()
.uri("http://httpbin.org:80")
.route("test3")
.order(-1)
.predicate(host("**.throttle.org").and(path("/get")))
.add(throttle.apply(tuple().of("capacity", 1,
"refillTokens", 1,
"refillPeriod", 10,
"refillUnit", "SECONDS")))
.uri("http://httpbin.org:80")
.build();
}</programlisting>
</para>