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
This commit is contained in:
parent
df5dfbf4be
commit
a00ee15e16
|
@ -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;
|
||||||
*/
|
*/
|
||||||
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 {
|
||||||
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");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue