Gateway 断言的配置方式
方式一,yml配置
spring:
cloud:
gateway:
routes:
- id: after_route
uri: http://httpbin.org/
filters:
- AddRequestHeader=X-Request-Foo, Bar
predicates:
- After=2017-01-20T17:42:47.789-07:00[America/Denver]
profiles: after_route
方式二:配置RouteLocator的bean,以流式api配置
@Bean
public RouteLocator customerRouteLocator(RouteLocatorBuilder builder) {
return builder.routes().
route(r -> r.path("/get/**")
.filters(f -> f.filter(new RequestTimeFilter()).addRequestHeader("X-Response-Default-Foo", "Default-Bar"))
.uri("http://httpbin.org").order(0).id("customer_filter_router")
)
.build();
}