Commit 29567a92 by Johannes Edmeier

Add proper ConfigProps class for endpoints

Annotating the applicationRouteLocator bean with @ConfigurationProperties yields the wrong configuration metadata. Instead do a explicit properties bean to get correct metadata. fixes #309
parent 9ebe92b6
......@@ -13,6 +13,8 @@ public class AdminServerProperties {
private MonitorProperties monitor = new MonitorProperties();
private RoutesProperties routes = new RoutesProperties();
public void setContextPath(String pathPrefix) {
if (!pathPrefix.startsWith("/") || pathPrefix.endsWith("/")) {
throw new IllegalArgumentException(
......@@ -29,6 +31,10 @@ public class AdminServerProperties {
return monitor;
}
public RoutesProperties getRoutes() {
return routes;
}
public static class MonitorProperties {
/**
* Time interval in ms to update the status of applications with expired statusInfo
......@@ -57,4 +63,20 @@ public class AdminServerProperties {
return statusLifetime;
}
}
public static class RoutesProperties {
/**
* Endpoints to be proxified by spring boot admin.
*/
private String[] endpoints = { "env", "metrics", "trace", "dump", "jolokia", "info",
"trace", "logfile", "refresh", "flyway", "liquibase", "heapdump" };
public String[] getEndpoints() {
return endpoints;
}
public void setEndpoints(String[] endpoints) {
this.endpoints = endpoints;
}
}
}
......@@ -22,7 +22,6 @@ import org.springframework.boot.actuate.endpoint.Endpoint;
import org.springframework.boot.actuate.trace.TraceRepository;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.netflix.zuul.RoutesEndpoint;
import org.springframework.cloud.netflix.zuul.ZuulConfiguration;
import org.springframework.cloud.netflix.zuul.filters.ProxyRequestHelper;
......@@ -65,10 +64,12 @@ public class RevereseZuulProxyConfiguration extends ZuulConfiguration {
@Bean
@Order(0)
@ConfigurationProperties("spring.boot.admin.routes")
public ApplicationRouteLocator applicationRouteLocator() {
return new ApplicationRouteLocator(this.server.getServletPrefix(), registry,
ApplicationRouteLocator routeLocator = new ApplicationRouteLocator(
this.server.getServletPrefix(), registry,
adminServer.getContextPath() + "/api/applications/");
routeLocator.setEndpoints(adminServer.getRoutes().getEndpoints());
return routeLocator;
}
@Bean
......
......@@ -43,17 +43,10 @@ public class ApplicationRouteLocator implements RefreshableRouteLocator {
private ApplicationRegistry registry;
private PathMatcher pathMatcher = new AntPathMatcher();
private AtomicReference<List<Route>> routes = new AtomicReference<>();
private String prefix;
private String servletPath;
/**
* Endpoints to be proxified by spring boot admin.
*/
private String[] endpoints = { "env", "metrics", "trace", "dump", "jolokia", "info", "trace",
"logfile", "refresh", "flyway", "liquibase", "heapdump" };
private String[] endpoints = {};
public ApplicationRouteLocator(String servletPath, ApplicationRegistry registry,
String prefix) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment