@Bean public RouteLocator sseRouteLocator(RouteLocatorBuilder builder) { return builder.routes() .route("sse_route", r -> r.alwaysTrue() .uri("http://localhost:"+this.port)) .build(); } }
@Bean public RouteLocator myRouteLocator(RouteLocatorBuilder builder) { return builder.routes() .route("test_metrics_happy_path", r -> r.host("*.metricshappypath.org") .uri(testUri)) .route("test_custom_http_status_metrics", r -> r.host("*.setcustomstatusmetrics.org") .filters(f -> f.setStatus(432)) .uri(testUri)) .build(); }
.uri("http://localhost:9099/error").order(-102)
@Bean public RouteLocator customRouteLocator(RouteLocatorBuilder builder) { //@formatter:off 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")) .route("websocket_route", r -> r.path("/echo") .uri("ws://localhost:9000")) .build(); //@formatter:on }