Search in sources :

Example 1 with WebMvcEndpointHandlerMapping

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

the class WebMvcEndpointIntegrationTests method webMvcEndpointHandlerMappingIsConfiguredWithPathPatternParser.

@Test
void webMvcEndpointHandlerMappingIsConfiguredWithPathPatternParser() {
    this.context = new AnnotationConfigServletWebApplicationContext();
    this.context.register(DefaultConfiguration.class);
    this.context.setServletContext(new MockServletContext());
    this.context.refresh();
    WebMvcEndpointHandlerMapping handlerMapping = this.context.getBean(WebMvcEndpointHandlerMapping.class);
    assertThat(handlerMapping.getPatternParser()).isEqualTo(WebMvcAutoConfiguration.pathPatternParser);
}
Also used : AnnotationConfigServletWebApplicationContext(org.springframework.boot.web.servlet.context.AnnotationConfigServletWebApplicationContext) WebMvcEndpointHandlerMapping(org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping) MockServletContext(org.springframework.mock.web.MockServletContext) Test(org.junit.jupiter.api.Test)

Example 2 with WebMvcEndpointHandlerMapping

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

the class WebMvcEndpointManagementContextConfiguration method webEndpointServletHandlerMapping.

@Bean
@ConditionalOnMissingBean
public WebMvcEndpointHandlerMapping webEndpointServletHandlerMapping(WebEndpointsSupplier webEndpointsSupplier, ServletEndpointsSupplier servletEndpointsSupplier, ControllerEndpointsSupplier controllerEndpointsSupplier, EndpointMediaTypes endpointMediaTypes, CorsEndpointProperties corsProperties, WebEndpointProperties webEndpointProperties, Environment environment) {
    List<ExposableEndpoint<?>> allEndpoints = new ArrayList<>();
    Collection<ExposableWebEndpoint> webEndpoints = webEndpointsSupplier.getEndpoints();
    allEndpoints.addAll(webEndpoints);
    allEndpoints.addAll(servletEndpointsSupplier.getEndpoints());
    allEndpoints.addAll(controllerEndpointsSupplier.getEndpoints());
    String basePath = webEndpointProperties.getBasePath();
    EndpointMapping endpointMapping = new EndpointMapping(basePath);
    boolean shouldRegisterLinksMapping = shouldRegisterLinksMapping(webEndpointProperties, environment, basePath);
    return new WebMvcEndpointHandlerMapping(endpointMapping, webEndpoints, endpointMediaTypes, corsProperties.toCorsConfiguration(), new EndpointLinksResolver(allEndpoints, basePath), shouldRegisterLinksMapping, WebMvcAutoConfiguration.pathPatternParser);
}
Also used : ExposableWebEndpoint(org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint) ExposableEndpoint(org.springframework.boot.actuate.endpoint.ExposableEndpoint) WebMvcEndpointHandlerMapping(org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping) 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) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

WebMvcEndpointHandlerMapping (org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping)2 ArrayList (java.util.ArrayList)1 Test (org.junit.jupiter.api.Test)1 ExposableEndpoint (org.springframework.boot.actuate.endpoint.ExposableEndpoint)1 EndpointLinksResolver (org.springframework.boot.actuate.endpoint.web.EndpointLinksResolver)1 EndpointMapping (org.springframework.boot.actuate.endpoint.web.EndpointMapping)1 ExposableWebEndpoint (org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint)1 ConditionalOnBean (org.springframework.boot.autoconfigure.condition.ConditionalOnBean)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 AnnotationConfigServletWebApplicationContext (org.springframework.boot.web.servlet.context.AnnotationConfigServletWebApplicationContext)1 Bean (org.springframework.context.annotation.Bean)1 MockServletContext (org.springframework.mock.web.MockServletContext)1