Merge branch '2.0.x'
This commit is contained in:
commit
8c691273e3
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package org.springframework.boot.actuate.endpoint.web;
|
package org.springframework.boot.actuate.endpoint.web;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -76,18 +77,21 @@ public class ServletEndpointRegistrar implements ServletContextInitializer {
|
||||||
EndpointServlet endpointServlet = endpoint.getEndpointServlet();
|
EndpointServlet endpointServlet = endpoint.getEndpointServlet();
|
||||||
Dynamic registration = servletContext.addServlet(name,
|
Dynamic registration = servletContext.addServlet(name,
|
||||||
endpointServlet.getServlet());
|
endpointServlet.getServlet());
|
||||||
registration.addMapping(getUrlMappings(endpoint.getRootPath(), name));
|
String[] urlMappings = getUrlMappings(endpoint.getRootPath());
|
||||||
|
registration.addMapping(urlMappings);
|
||||||
|
if (logger.isInfoEnabled()) {
|
||||||
|
Arrays.stream(urlMappings).forEach(
|
||||||
|
(mapping) -> logger.info("Registered '" + mapping + "' to " + name));
|
||||||
|
}
|
||||||
registration.setInitParameters(endpointServlet.getInitParameters());
|
registration.setInitParameters(endpointServlet.getInitParameters());
|
||||||
}
|
}
|
||||||
|
|
||||||
private String[] getUrlMappings(String endpointPath, String name) {
|
private String[] getUrlMappings(String endpointPath) {
|
||||||
return this.basePaths
|
return this.basePaths.stream()
|
||||||
.stream().map((basePath) -> (basePath != null
|
.map((basePath) -> (basePath != null ? basePath + "/" + endpointPath
|
||||||
? basePath + "/" + endpointPath : "/" + endpointPath))
|
: "/" + endpointPath))
|
||||||
.distinct().map((path) -> {
|
.distinct().map((path) -> (path.endsWith("/") ? path + "*" : path + "/*"))
|
||||||
logger.info("Registered '" + path + "' to " + name);
|
.toArray(String[]::new);
|
||||||
return (path.endsWith("/") ? path + "*" : path + "/*");
|
|
||||||
}).toArray(String[]::new);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue