diff --git a/docs/src/main/asciidoc/spring-cloud-netflix.adoc b/docs/src/main/asciidoc/spring-cloud-netflix.adoc index 2f0ee6db..f4ef13c3 100644 --- a/docs/src/main/asciidoc/spring-cloud-netflix.adoc +++ b/docs/src/main/asciidoc/spring-cloud-netflix.adoc @@ -1121,7 +1121,7 @@ specified as an ant-style pattern, so "/myusers/{asterisk}" only matches one level, but "/myusers/{all}" matches hierarchically. The location of the backend can be specified as either a "serviceId" -(for a Eureka service) or a "url" (for a physical location), e.g. +(for a service from discovery) or a "url" (for a physical location), e.g. .application.yml [source,yaml] @@ -1286,6 +1286,18 @@ classpath, and otherwise they are initialized to a set of well-known Security. The assumption in this case is that the downstream services might add these headers too, and we want the values from the proxy. +=== The Routes Endpoint + +If you are using `@EnableZuulProxy` with tha Spring Boot Actuator you +will enable (by default) an additional endpoint, available via HTTP as +`/routes`. A GET to this endpoint will return a list of the mapped +routes. A POST will force a refresh of the existing routes (e.g. in +case there have been changes in the service catalog). + +NOTE: the routes should respond automatically to changes in the +service catalog, but the POST to /routes is a way to force the change +to happen immediately. + === Strangulation Patterns and Local Forwards A common pattern when migrating an existing application or API is to diff --git a/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/ZuulConfiguration.java b/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/ZuulConfiguration.java index c3b2a023..cc5a5d0b 100644 --- a/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/ZuulConfiguration.java +++ b/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/ZuulConfiguration.java @@ -27,6 +27,8 @@ import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfigurat import org.springframework.boot.context.embedded.ServletRegistrationBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.cloud.client.actuator.HasFeatures; +import org.springframework.cloud.client.discovery.event.HeartbeatEvent; +import org.springframework.cloud.client.discovery.event.HeartbeatMonitor; import org.springframework.cloud.context.scope.refresh.RefreshScopeRefreshedEvent; import org.springframework.cloud.netflix.zuul.filters.RouteLocator; import org.springframework.cloud.netflix.zuul.filters.SimpleRouteLocator; @@ -168,6 +170,8 @@ public class ZuulConfiguration { @Autowired private ZuulHandlerMapping zuulHandlerMapping; + private HeartbeatMonitor heartbeatMonitor = new HeartbeatMonitor(); + @Override public void onApplicationEvent(ApplicationEvent event) { if (event instanceof ContextRefreshedEvent @@ -175,6 +179,11 @@ public class ZuulConfiguration { || event instanceof RoutesRefreshedEvent) { this.zuulHandlerMapping.setDirty(true); } + else if (event instanceof HeartbeatEvent) { + if (this.heartbeatMonitor.update(((HeartbeatEvent) event).getValue())) { + this.zuulHandlerMapping.setDirty(true); + } + } } }