Merge branch '2.0.x'
This commit is contained in:
@@ -198,7 +198,7 @@ public final class EndpointRequest {
|
|||||||
if (this.includeLinks
|
if (this.includeLinks
|
||||||
&& StringUtils.hasText(pathMappedEndpoints.getBasePath())) {
|
&& StringUtils.hasText(pathMappedEndpoints.getBasePath())) {
|
||||||
delegateMatchers.add(new AntPathRequestMatcher(
|
delegateMatchers.add(new AntPathRequestMatcher(
|
||||||
servletPath + pathMappedEndpoints.getBasePath()));
|
computePath(servletPath, pathMappedEndpoints.getBasePath())));
|
||||||
}
|
}
|
||||||
return new OrRequestMatcher(delegateMatchers);
|
return new OrRequestMatcher(delegateMatchers);
|
||||||
}
|
}
|
||||||
@@ -229,10 +229,17 @@ public final class EndpointRequest {
|
|||||||
private List<RequestMatcher> getDelegateMatchers(String servletPath,
|
private List<RequestMatcher> getDelegateMatchers(String servletPath,
|
||||||
Set<String> paths) {
|
Set<String> paths) {
|
||||||
return paths.stream()
|
return paths.stream()
|
||||||
.map((path) -> new AntPathRequestMatcher(servletPath + path + "/**"))
|
.map((path) -> new AntPathRequestMatcher(computePath(servletPath, path) + "/**"))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String computePath(String servletPath, String path) {
|
||||||
|
if (servletPath.equals("/")) {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
return servletPath + path;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean matches(HttpServletRequest request,
|
protected boolean matches(HttpServletRequest request,
|
||||||
Supplier<WebApplicationContext> context) {
|
Supplier<WebApplicationContext> context) {
|
||||||
@@ -272,11 +279,18 @@ public final class EndpointRequest {
|
|||||||
private RequestMatcher createDelegate(String path,
|
private RequestMatcher createDelegate(String path,
|
||||||
WebEndpointProperties properties) {
|
WebEndpointProperties properties) {
|
||||||
if (StringUtils.hasText(properties.getBasePath())) {
|
if (StringUtils.hasText(properties.getBasePath())) {
|
||||||
return new AntPathRequestMatcher(path + properties.getBasePath());
|
return new AntPathRequestMatcher(computePath(path, properties.getBasePath()));
|
||||||
}
|
}
|
||||||
return EMPTY_MATCHER;
|
return EMPTY_MATCHER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String computePath(String servletPath, String path) {
|
||||||
|
if (servletPath.equals("/")) {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
return servletPath + path;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean matches(HttpServletRequest request,
|
protected boolean matches(HttpServletRequest request,
|
||||||
Supplier<WebApplicationContext> context) {
|
Supplier<WebApplicationContext> context) {
|
||||||
|
|||||||
@@ -52,9 +52,9 @@ public class EndpointRequestTests {
|
|||||||
@Test
|
@Test
|
||||||
public void toAnyEndpointShouldMatchEndpointPath() {
|
public void toAnyEndpointShouldMatchEndpointPath() {
|
||||||
RequestMatcher matcher = EndpointRequest.toAnyEndpoint();
|
RequestMatcher matcher = EndpointRequest.toAnyEndpoint();
|
||||||
assertMatcher(matcher).matches("/actuator/foo");
|
assertMatcher(matcher, "/actuator", "/").matches("/actuator/foo");
|
||||||
assertMatcher(matcher).matches("/actuator/bar");
|
assertMatcher(matcher, "/actuator", "/").matches("/actuator/bar");
|
||||||
assertMatcher(matcher).matches("/actuator");
|
assertMatcher(matcher, "/actuator", "/").matches("/actuator");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user