先にジャンプ
VMware は、あなたの進歩を加速させるトレーニングと認定を提供します。
さらに学習したい方に (英語)このプロジェクトは、Spring WebFlux 上に API ゲートウェイを構築するためのライブラリを提供します。Spring Cloud Gateway は、API へのルーティングと、セキュリティ、監視 / メトリクス、回復力などの横断的な関心事を提供するためのシンプルかつ効果的な方法を提供することを目的としています。
Spring Cloud Gateway の機能:
@SpringBootApplication
public class DemogatewayApplication {
@Bean
public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
return builder.routes()
.route("path_route", r -> r.path("/get")
.uri("http://httpbin.org"))
.route("host_route", r -> r.host("*.myhost.org")
.uri("http://httpbin.org"))
.route("rewrite_route", r -> r.host("*.rewrite.org")
.filters(f -> f.rewritePath("/foo/(?<segment>.*)", "/${segment}"))
.uri("http://httpbin.org"))
.route("hystrix_route", r -> r.host("*.hystrix.org")
.filters(f -> f.hystrix(c -> c.setName("slowcmd")))
.uri("http://httpbin.org"))
.route("hystrix_fallback_route", r -> r.host("*.hystrixfallback.org")
.filters(f -> f.hystrix(c -> c.setName("slowcmd").setFallbackUri("forward:/hystrixfallback")))
.uri("http://httpbin.org"))
.route("limit_route", r -> r
.host("*.limited.org").and().path("/anything/**")
.filters(f -> f.requestRateLimiter(c -> c.setRateLimiter(redisRateLimiter())))
.uri("http://httpbin.org"))
.build();
}
}
独自のゲートウェイを実行するには、spring-cloud-starter-gateway
依存関係を使用します。