diff --git a/2.0.x/multi/multi__configuration.html b/2.0.x/multi/multi__configuration.html index 1ffb52ce..5fcc749c 100644 --- a/2.0.x/multi/multi__configuration.html +++ b/2.0.x/multi/multi__configuration.html @@ -20,21 +20,27 @@ uri: http://example.org filters: - SetStatus=401
-
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 RouteDefinitionLocator implementations based off of Spring Data Repositories such as: Redis, MongoDB and Cassandra.
To allow for simple configuration in Java, there is a fluent API defined in the Routes class.
Config.java. +
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 RouteDefinitionLocator implementations based off of Spring Data Repositories such as: Redis, MongoDB and Cassandra.
To allow for simple configuration in Java, there is a fluent API defined in the Routes class.
GatewaySampleApplication.java.
// 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(); }
This style also allows for more custom predicate assertions. The predicates defined by RouteDefinitionLocator beans are combined using logical and. By using the fluent Java API, you can use the and(), or() and negate() operators on the Predicate class.