Search in sources :

Example 6 with ExposableWebEndpoint

use of org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint in project spring-boot by spring-projects.

the class WebMvcEndpointManagementContextConfiguration method managementHealthEndpointWebMvcHandlerMapping.

@Bean
@ConditionalOnManagementPort(ManagementPortType.DIFFERENT)
@ConditionalOnBean(HealthEndpoint.class)
@ConditionalOnAvailableEndpoint(endpoint = HealthEndpoint.class, exposure = EndpointExposure.WEB)
public AdditionalHealthEndpointPathsWebMvcHandlerMapping managementHealthEndpointWebMvcHandlerMapping(WebEndpointsSupplier webEndpointsSupplier, HealthEndpointGroups groups) {
    Collection<ExposableWebEndpoint> webEndpoints = webEndpointsSupplier.getEndpoints();
    ExposableWebEndpoint health = webEndpoints.stream().filter((endpoint) -> endpoint.getEndpointId().equals(HealthEndpoint.ID)).findFirst().get();
    return new AdditionalHealthEndpointPathsWebMvcHandlerMapping(health, groups.getAllWithAdditionalPath(WebServerNamespace.MANAGEMENT));
}
Also used : ExposableWebEndpoint(org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint) AdditionalHealthEndpointPathsWebMvcHandlerMapping(org.springframework.boot.actuate.endpoint.web.servlet.AdditionalHealthEndpointPathsWebMvcHandlerMapping) ConditionalOnAvailableEndpoint(org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnAvailableEndpoint) ConditionalOnBean(org.springframework.boot.autoconfigure.condition.ConditionalOnBean) ConditionalOnManagementPort(org.springframework.boot.actuate.autoconfigure.web.server.ConditionalOnManagementPort) ConditionalOnBean(org.springframework.boot.autoconfigure.condition.ConditionalOnBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 7 with ExposableWebEndpoint

use of org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint in project spring-boot by spring-projects.

the class ReactiveCloudFoundryActuatorAutoConfiguration method cloudFoundryWebFluxEndpointHandlerMapping.

@Bean
public CloudFoundryWebFluxEndpointHandlerMapping cloudFoundryWebFluxEndpointHandlerMapping(ParameterValueMapper parameterMapper, EndpointMediaTypes endpointMediaTypes, WebClient.Builder webClientBuilder, ControllerEndpointsSupplier controllerEndpointsSupplier, ApplicationContext applicationContext) {
    CloudFoundryWebEndpointDiscoverer endpointDiscoverer = new CloudFoundryWebEndpointDiscoverer(applicationContext, parameterMapper, endpointMediaTypes, null, Collections.emptyList(), Collections.emptyList());
    CloudFoundrySecurityInterceptor securityInterceptor = getSecurityInterceptor(webClientBuilder, applicationContext.getEnvironment());
    Collection<ExposableWebEndpoint> webEndpoints = endpointDiscoverer.getEndpoints();
    List<ExposableEndpoint<?>> allEndpoints = new ArrayList<>();
    allEndpoints.addAll(webEndpoints);
    allEndpoints.addAll(controllerEndpointsSupplier.getEndpoints());
    return new CloudFoundryWebFluxEndpointHandlerMapping(new EndpointMapping("/cloudfoundryapplication"), webEndpoints, endpointMediaTypes, getCorsConfiguration(), securityInterceptor, new EndpointLinksResolver(allEndpoints));
}
Also used : CloudFoundryWebEndpointDiscoverer(org.springframework.boot.actuate.autoconfigure.cloudfoundry.CloudFoundryWebEndpointDiscoverer) ExposableWebEndpoint(org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint) ExposableEndpoint(org.springframework.boot.actuate.endpoint.ExposableEndpoint) ArrayList(java.util.ArrayList) EndpointLinksResolver(org.springframework.boot.actuate.endpoint.web.EndpointLinksResolver) EndpointMapping(org.springframework.boot.actuate.endpoint.web.EndpointMapping) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnBean(org.springframework.boot.autoconfigure.condition.ConditionalOnBean) Bean(org.springframework.context.annotation.Bean)

Example 8 with ExposableWebEndpoint

use of org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint in project spring-boot by spring-projects.

the class WebEndpointDiscovererTests method getEndpointsWhenHasCustomMediaTypeShouldProduceCustomMediaType.

@Test
void getEndpointsWhenHasCustomMediaTypeShouldProduceCustomMediaType() {
    load(CustomMediaTypesEndpointConfiguration.class, (discoverer) -> {
        Map<EndpointId, ExposableWebEndpoint> endpoints = mapEndpoints(discoverer.getEndpoints());
        assertThat(endpoints).containsOnlyKeys(EndpointId.of("custommediatypes"));
        ExposableWebEndpoint endpoint = endpoints.get(EndpointId.of("custommediatypes"));
        assertThat(requestPredicates(endpoint)).has(requestPredicates(path("custommediatypes").httpMethod(WebEndpointHttpMethod.GET).consumes().produces("text/plain"), path("custommediatypes").httpMethod(WebEndpointHttpMethod.POST).consumes().produces("a/b", "c/d"), path("custommediatypes").httpMethod(WebEndpointHttpMethod.DELETE).consumes().produces("text/plain")));
    });
}
Also used : ExposableWebEndpoint(org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint) EndpointId(org.springframework.boot.actuate.endpoint.EndpointId) Test(org.junit.jupiter.api.Test)

Example 9 with ExposableWebEndpoint

use of org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint in project spring-boot by spring-projects.

the class WebEndpointDiscovererTests method getEndpointsWhenExtensionAddsOperationShouldHaveBothOperations.

@Test
void getEndpointsWhenExtensionAddsOperationShouldHaveBothOperations() {
    load(AdditionalOperationWebEndpointConfiguration.class, (discoverer) -> {
        Map<EndpointId, ExposableWebEndpoint> endpoints = mapEndpoints(discoverer.getEndpoints());
        assertThat(endpoints).containsOnlyKeys(EndpointId.of("test"));
        ExposableWebEndpoint endpoint = endpoints.get(EndpointId.of("test"));
        assertThat(requestPredicates(endpoint)).has(requestPredicates(path("test").httpMethod(WebEndpointHttpMethod.GET).consumes().produces("application/json"), path("test/{id}").httpMethod(WebEndpointHttpMethod.GET).consumes().produces("application/json")));
    });
}
Also used : ExposableWebEndpoint(org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint) EndpointId(org.springframework.boot.actuate.endpoint.EndpointId) Test(org.junit.jupiter.api.Test)

Example 10 with ExposableWebEndpoint

use of org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint in project spring-boot by spring-projects.

the class WebEndpointDiscovererTests method getEndpointsWhenHasCustomPathShouldReturnCustomPath.

@Test
void getEndpointsWhenHasCustomPathShouldReturnCustomPath() {
    load((id) -> null, (id) -> "custom/" + id, AdditionalOperationWebEndpointConfiguration.class, (discoverer) -> {
        Map<EndpointId, ExposableWebEndpoint> endpoints = mapEndpoints(discoverer.getEndpoints());
        assertThat(endpoints).containsOnlyKeys(EndpointId.of("test"));
        ExposableWebEndpoint endpoint = endpoints.get(EndpointId.of("test"));
        Condition<List<? extends WebOperationRequestPredicate>> expected = requestPredicates(path("custom/test").httpMethod(WebEndpointHttpMethod.GET).consumes().produces("application/json"), path("custom/test/{id}").httpMethod(WebEndpointHttpMethod.GET).consumes().produces("application/json"));
        assertThat(requestPredicates(endpoint)).has(expected);
    });
}
Also used : WebOperationRequestPredicate(org.springframework.boot.actuate.endpoint.web.WebOperationRequestPredicate) ExposableWebEndpoint(org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint) EndpointId(org.springframework.boot.actuate.endpoint.EndpointId) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.jupiter.api.Test)

Aggregations

ExposableWebEndpoint (org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint)19 Test (org.junit.jupiter.api.Test)13 EndpointId (org.springframework.boot.actuate.endpoint.EndpointId)7 WebOperation (org.springframework.boot.actuate.endpoint.web.WebOperation)6 ConditionalOnBean (org.springframework.boot.autoconfigure.condition.ConditionalOnBean)6 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)6 Bean (org.springframework.context.annotation.Bean)6 ArrayList (java.util.ArrayList)5 EndpointMapping (org.springframework.boot.actuate.endpoint.web.EndpointMapping)5 ExposableEndpoint (org.springframework.boot.actuate.endpoint.ExposableEndpoint)4 EndpointLinksResolver (org.springframework.boot.actuate.endpoint.web.EndpointLinksResolver)4 CloudFoundryWebEndpointDiscoverer (org.springframework.boot.actuate.autoconfigure.cloudfoundry.CloudFoundryWebEndpointDiscoverer)2 ConditionalOnAvailableEndpoint (org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnAvailableEndpoint)2 ConditionalOnManagementPort (org.springframework.boot.actuate.autoconfigure.web.server.ConditionalOnManagementPort)2 List (java.util.List)1 HealthEndpointAutoConfiguration (org.springframework.boot.actuate.autoconfigure.health.HealthEndpointAutoConfiguration)1 InvocationContext (org.springframework.boot.actuate.endpoint.InvocationContext)1 CachingOperationInvoker (org.springframework.boot.actuate.endpoint.invoker.cache.CachingOperationInvoker)1 WebOperationRequestPredicate (org.springframework.boot.actuate.endpoint.web.WebOperationRequestPredicate)1 WebEndpointDiscoverer (org.springframework.boot.actuate.endpoint.web.annotation.WebEndpointDiscoverer)1