Provide links for actuators at / when using a separate management port
See gh-17418
This commit is contained in:
committed by
Madhura Bhave
parent
edea223841
commit
c108629311
@@ -28,12 +28,20 @@ public class EndpointMapping {
|
||||
|
||||
private final String path;
|
||||
|
||||
private final Boolean samePort;
|
||||
|
||||
/**
|
||||
* Creates a new {@code EndpointMapping} using the given {@code path}.
|
||||
* @param path the path
|
||||
* @param samePort states true or false for same port as server
|
||||
*/
|
||||
public EndpointMapping(String path) {
|
||||
public EndpointMapping(String path, Boolean samePort) {
|
||||
this.path = normalizePath(path);
|
||||
this.samePort = samePort;
|
||||
}
|
||||
|
||||
public EndpointMapping(String path) {
|
||||
this(path, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,6 +52,10 @@ public class EndpointMapping {
|
||||
return this.path;
|
||||
}
|
||||
|
||||
public boolean isSamePort() {
|
||||
return this.samePort;
|
||||
}
|
||||
|
||||
public String createSubPath(String path) {
|
||||
return this.path + normalizePath(path);
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ public class JerseyEndpointResourceFactory {
|
||||
List<Resource> resources = new ArrayList<>();
|
||||
endpoints.stream().flatMap((endpoint) -> endpoint.getOperations().stream())
|
||||
.map((operation) -> createResource(endpointMapping, operation)).forEach(resources::add);
|
||||
if (StringUtils.hasText(endpointMapping.getPath())) {
|
||||
if (StringUtils.hasText(endpointMapping.getPath()) || !endpointMapping.isSamePort()) {
|
||||
Resource resource = createEndpointLinksResource(endpointMapping.getPath(), endpointMediaTypes,
|
||||
linksResolver);
|
||||
resources.add(resource);
|
||||
|
||||
@@ -120,7 +120,7 @@ public abstract class AbstractWebFluxEndpointHandlerMapping extends RequestMappi
|
||||
registerMappingForOperation(endpoint, operation);
|
||||
}
|
||||
}
|
||||
if (StringUtils.hasText(this.endpointMapping.getPath())) {
|
||||
if (StringUtils.hasText(this.endpointMapping.getPath()) || !this.endpointMapping.isSamePort()) {
|
||||
registerLinksMapping();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ public abstract class AbstractWebMvcEndpointHandlerMapping extends RequestMappin
|
||||
registerMappingForOperation(endpoint, operation);
|
||||
}
|
||||
}
|
||||
if (StringUtils.hasText(this.endpointMapping.getPath())) {
|
||||
if (StringUtils.hasText(this.endpointMapping.getPath()) || !this.endpointMapping.isSamePort()) {
|
||||
registerLinksMapping();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,4 +77,9 @@ class EndpointMappingTests {
|
||||
assertThat(new EndpointMapping("/test").createSubPath("one/")).isEqualTo("/test/one");
|
||||
}
|
||||
|
||||
@Test
|
||||
void setDifferentPort() {
|
||||
assertThat(new EndpointMapping("/test", false).isSamePort()).isFalse();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user