use of org.springframework.boot.actuate.endpoint.mvc.NamedMvcEndpoint in project spring-boot by spring-projects.
the class CloudFoundryEndpointHandlerMapping method postProcessEndpoints.
@Override
protected void postProcessEndpoints(Set<NamedMvcEndpoint> endpoints) {
super.postProcessEndpoints(endpoints);
Iterator<NamedMvcEndpoint> iterator = endpoints.iterator();
HealthMvcEndpoint healthMvcEndpoint = null;
while (iterator.hasNext()) {
NamedMvcEndpoint endpoint = iterator.next();
if (endpoint instanceof HalJsonMvcEndpoint) {
iterator.remove();
} else if (endpoint instanceof HealthMvcEndpoint) {
iterator.remove();
healthMvcEndpoint = (HealthMvcEndpoint) endpoint;
}
}
if (healthMvcEndpoint != null) {
endpoints.add(new CloudFoundryHealthMvcEndpoint(healthMvcEndpoint.getDelegate()));
}
}
use of org.springframework.boot.actuate.endpoint.mvc.NamedMvcEndpoint in project spring-boot by spring-projects.
the class CloudFoundryDiscoveryMvcEndpointTests method setup.
@Before
public void setup() {
NamedMvcEndpoint endpoint = new TestMvcEndpoint(new TestEndpoint("a"));
this.endpoints = new LinkedHashSet<>();
this.endpoints.add(endpoint);
this.endpoint = new CloudFoundryDiscoveryMvcEndpoint(this.endpoints);
}
use of org.springframework.boot.actuate.endpoint.mvc.NamedMvcEndpoint in project spring-boot by spring-projects.
the class CloudFoundryDiscoveryMvcEndpointTests method linksResponseWhenRequestHasAccessLevelRestricted.
@Test
public void linksResponseWhenRequestHasAccessLevelRestricted() throws Exception {
NamedMvcEndpoint testHealthMvcEndpoint = new TestMvcEndpoint(new TestEndpoint("health"));
this.endpoints.add(testHealthMvcEndpoint);
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/cloudfoundryapplication/");
AccessLevel.RESTRICTED.put(request);
Map<String, CloudFoundryDiscoveryMvcEndpoint.Link> links = this.endpoint.links(request).get("_links");
assertThat(links.get("self").getHref()).isEqualTo("http://localhost/cloudfoundryapplication");
assertThat(links.get("health").getHref()).isEqualTo("http://localhost/cloudfoundryapplication/health");
assertThat(links.get("a")).isNull();
}
use of org.springframework.boot.actuate.endpoint.mvc.NamedMvcEndpoint in project spring-boot by spring-projects.
the class CloudFoundryActuatorAutoConfiguration method cloudFoundryEndpointHandlerMapping.
@Bean
public CloudFoundryEndpointHandlerMapping cloudFoundryEndpointHandlerMapping(MvcEndpoints mvcEndpoints, RestTemplateBuilder restTemplateBuilder, Environment environment) {
Set<NamedMvcEndpoint> endpoints = new LinkedHashSet<>(mvcEndpoints.getEndpoints(NamedMvcEndpoint.class));
HandlerInterceptor securityInterceptor = getSecurityInterceptor(restTemplateBuilder, environment);
CorsConfiguration corsConfiguration = getCorsConfiguration();
CloudFoundryEndpointHandlerMapping mapping = new CloudFoundryEndpointHandlerMapping(endpoints, corsConfiguration, securityInterceptor);
mapping.setPrefix("/cloudfoundryapplication");
return mapping;
}
use of org.springframework.boot.actuate.endpoint.mvc.NamedMvcEndpoint in project spring-boot by spring-projects.
the class CloudFoundryDiscoveryMvcEndpoint method links.
@RequestMapping(produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public Map<String, Map<String, Link>> links(HttpServletRequest request) {
Map<String, Link> links = new LinkedHashMap<>();
String url = request.getRequestURL().toString();
if (url.endsWith("/")) {
url = url.substring(0, url.length() - 1);
}
links.put("self", Link.withHref(url));
AccessLevel accessLevel = AccessLevel.get(request);
for (NamedMvcEndpoint endpoint : this.endpoints) {
if (accessLevel != null && accessLevel.isAccessAllowed(endpoint.getPath())) {
links.put(endpoint.getName(), Link.withHref(url + "/" + endpoint.getName()));
}
}
return Collections.singletonMap("_links", links);
}
Aggregations