|
@@ -15,23 +15,20 @@ public class RouterConfig {
|
15
|
15
|
//@formatter:off
|
16
|
16
|
return builder.routes()
|
17
|
17
|
.route("path_route", r -> r.path("/city_list.do")
|
|
18
|
+ .filters(f -> f.requestRateLimiter(c -> c.setRateLimiter(redisRateLimiter())))
|
18
|
19
|
.uri("https://api.bbztx.com"))
|
19
|
20
|
.route("host_route", r -> r.host("*.myhost.org")
|
20
|
21
|
.uri("http://httpbin.org"))
|
21
|
|
-// .route("rewrite_route", r -> r.host("*.rewrite.org")
|
22
|
|
-// .filters(f -> f.rewritePath("/foo/(?<segment>.*)",
|
23
|
|
-// "/${segment}"))
|
24
|
|
-// .uri("http://httpbin.org"))
|
|
22
|
+ .route("rewrite_route", r -> r.path("/city_list")
|
|
23
|
+ .filters(f -> f.rewritePath("city_list", // rewritePath方法会使用内建的过滤器重写路径
|
|
24
|
+ "city_list.do"))
|
|
25
|
+ .uri("https://api.bbztx.com"))
|
25
|
26
|
// .route("hystrix_route", r -> r.host("*.hystrix.org")
|
26
|
27
|
// .filters(f -> f.hystrix(c -> c.setName("slowcmd")))
|
27
|
28
|
// .uri("http://httpbin.org"))
|
28
|
29
|
// .route("hystrix_fallback_route", r -> r.host("*.hystrixfallback.org")
|
29
|
30
|
// .filters(f -> f.hystrix(c -> c.setName("slowcmd").setFallbackUri("forward:/hystrixfallback")))
|
30
|
31
|
// .uri("http://httpbin.org"))
|
31
|
|
-// .route("limit_route", r -> r
|
32
|
|
-// .host("*.limited.org").and().path("/anything/**")
|
33
|
|
-// .filters(f -> f.requestRateLimiter(c -> c.setRateLimiter(redisRateLimiter())))
|
34
|
|
-// .uri("http://httpbin.org"))
|
35
|
32
|
// .route("websocket_route", r -> r.path("/echo")
|
36
|
33
|
// .uri("ws://localhost:9000"))
|
37
|
34
|
.build();
|
|
@@ -40,6 +37,6 @@ public class RouterConfig {
|
40
|
37
|
|
41
|
38
|
@Bean
|
42
|
39
|
RedisRateLimiter redisRateLimiter() {
|
43
|
|
- return new RedisRateLimiter(1, 2);
|
|
40
|
+ return new RedisRateLimiter(2, 4);
|
44
|
41
|
}
|
45
|
42
|
}
|