Commit a00ee15e authored by Phillip Webb's avatar Phillip Webb

Use lowercase default endpoint paths

Update `MappingWebEndpointPathMapper` to use the lowercase version of
the endpoint ID when no explicit path mapping has been set. An endpoint
with the ID 'myEndpoint' will now be mapped to the path 'myendpoint'.

See gh-14773
parent df5dfbf4
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
package org.springframework.boot.actuate.autoconfigure.endpoint.web; package org.springframework.boot.actuate.autoconfigure.endpoint.web;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.springframework.boot.actuate.endpoint.EndpointId; import org.springframework.boot.actuate.endpoint.EndpointId;
...@@ -29,10 +30,12 @@ import org.springframework.boot.actuate.endpoint.web.PathMapper; ...@@ -29,10 +30,12 @@ import org.springframework.boot.actuate.endpoint.web.PathMapper;
*/ */
class MappingWebEndpointPathMapper implements PathMapper { class MappingWebEndpointPathMapper implements PathMapper {
private final Map<String, String> pathMapping; private final Map<EndpointId, String> pathMapping;
MappingWebEndpointPathMapper(Map<String, String> pathMapping) { MappingWebEndpointPathMapper(Map<String, String> pathMapping) {
this.pathMapping = pathMapping; this.pathMapping = new HashMap<>();
pathMapping.forEach((id, path) -> this.pathMapping
.put(EndpointId.fromPropertyValue(id), path));
} }
@Override @Override
......
...@@ -45,4 +45,19 @@ public class MappingWebEndpointPathMapperTests { ...@@ -45,4 +45,19 @@ public class MappingWebEndpointPathMapperTests {
assertThat(mapper.getRootPath(EndpointId.of("test"))).isEqualTo("custom"); assertThat(mapper.getRootPath(EndpointId.of("test"))).isEqualTo("custom");
} }
@Test
public void mixedCaseDefaultConfiguration() {
MappingWebEndpointPathMapper mapper = new MappingWebEndpointPathMapper(
Collections.emptyMap());
assertThat(mapper.getRootPath(EndpointId.of("testEndpoint")))
.isEqualTo("testendpoint");
}
@Test
public void mixedCaseUserConfiguration() {
MappingWebEndpointPathMapper mapper = new MappingWebEndpointPathMapper(
Collections.singletonMap("test-endpoint", "custom"));
assertThat(mapper.getRootPath(EndpointId.of("testEndpoint"))).isEqualTo("custom");
}
} }
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