http://gibb.tech
@spencerbgibb
https://slides.com/spencer/spring-cloud-gateway/live
http://ryanjbaxter.com
@ryanjbaxter
https://slides.com/spencer/spring-cloud-gateway/live
@spencerbgibb
https://slides.com/spencer/spring-cloud-gateway/live
@sreetummidi
http://spencer.gibb.us
@spencerbgibb
https://slides.com/spencer/spring-cloud-gateway/live
http://microservices.io/patterns/apigateway.html
Server Side
MVC App
Single Page
JS App
or
Mobile App
API Gateway
Product Service
Recommendation Service
User Service
https://www.youtube.com/watch?v=mHHHpxJuTAo
Project
Reactor
Filter AAA
Filter BBB
Filter CCC
* (Global Filters)
Hystrix+Ribbon+Spring Retry
public class SetStatusWebFilterFactory implements GatewayFilterFactory {
@Override
public GatewayFilter apply(Config config) {
final HttpStatus status = parse(config.status);
return (exchange, chain) -> chain.filter(exchange)
.then(Mono.fromRunnable(() -> {
setResponseStatus(exchange, httpStatus);
}));
}
}
spring:
cloud:
gateway:
- id: foo_route
uri: lb://foo
predicates:
- Host=**.foo.org
- Path=/headers
- Method=GET
- Header=X-Request-Id, \d+
- Query=foo, ba.
- Query=baz
- Cookie=chocolate, ch.p
- After=1900-01-20T17:42:47.789-07:00[America/Denver]
filters:
- AddRequestHeader=X-Request-Foo, Bar
- AddResponseHeader=X-Response-Foo, Bar
- Hystrix=foo
- SecureHeaders
- RewritePath=/foo/(?<segment>.*), /$\{segment}
@Bean
public RouteLocator customRouteLocator(RouteLocatorBuilder builder,
ThrottleGatewayFilterFactory throttle) {
return builder.routes()
.route(r -> r.host("**.abc.org").and().path("/image/png")
.filters(f -> f.addResponseHeader("X-TestHeader", "foobar"))
.uri("http://httpbin.org:80")
)
.route(r -> r.path("/image/webp")
.filters(f -> f.addResponseHeader("X-AnotherHeader", "baz"))
.uri("http://httpbin.org:80")
)
.route(r -> r.order(-1)
.host("**.throttle.org").and().path("/get")
.filters(f -> f.filter(throttle.apply(1, 1, 10,
TimeUnit.SECONDS)))
.uri("http://httpbin.org:80")
)
.build();
}
@spencerbgibb
http://slides.com/spencer/spring-cloud-gateway
https://github.com/spring-cloud/spring-cloud-gateway
https://github.com/spring-cloud-samples/spring-cloud-gateway-sample
@ryanjbaxter
http://slides.com/spencer/spring-cloud-gateway
https://github.com/spring-cloud/spring-cloud-gateway
https://github.com/spring-cloud-samples/spring-cloud-gateway-sample