Make uri() terminating operator in Routes.

Simplifies dsl and make it easier to read.
This commit is contained in:
Spencer Gibb
2017-10-13 12:40:03 -04:00
parent 5a23335375
commit 279cd03578
4 changed files with 42 additions and 37 deletions

View File

@@ -45,24 +45,21 @@ public class GatewaySampleApplication {
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)
.uri("http://httpbin.org:80")
.predicate(host("**.throttle.org").and(path("/get")))
.add(throttle.apply(tuple().of("capacity", 1,
"refillTokens", 1,
"refillPeriod", 10,
"refillUnit", "SECONDS")))
.and()
.uri("http://httpbin.org:80")
.build();
}