From fac223a91b99e94130cdd3f25a612c9dda1e55a4 Mon Sep 17 00:00:00 2001 From: Spencer Gibb Date: Fri, 27 Jan 2017 17:15:32 -0700 Subject: [PATCH] Makes DiscoveryClientRouteReader route ids pretty. Uses simple class name of discovery client and the serviceId separated by an _ --- .../cloud/gateway/discovery/DiscoveryClientRouteReader.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/org/springframework/cloud/gateway/discovery/DiscoveryClientRouteReader.java b/src/main/java/org/springframework/cloud/gateway/discovery/DiscoveryClientRouteReader.java index 075526b2..9d3b53ab 100644 --- a/src/main/java/org/springframework/cloud/gateway/discovery/DiscoveryClientRouteReader.java +++ b/src/main/java/org/springframework/cloud/gateway/discovery/DiscoveryClientRouteReader.java @@ -16,9 +16,11 @@ import java.net.URI; public class DiscoveryClientRouteReader implements RouteReader { private final DiscoveryClient discoveryClient; + private final String routeIdPrefix; public DiscoveryClientRouteReader(DiscoveryClient discoveryClient) { this.discoveryClient = discoveryClient; + this.routeIdPrefix = this.discoveryClient.getClass().getSimpleName() + "_"; } @Override @@ -26,6 +28,7 @@ public class DiscoveryClientRouteReader implements RouteReader { return Flux.fromIterable(discoveryClient.getServices()) .map(serviceId -> { Route route = new Route(); + route.setId(this.routeIdPrefix + serviceId); route.setUri(URI.create("lb://" + serviceId)); // add a predicate that matches the url at /serviceId/**