Search in sources :

Example 1 with WebOperationRequestPredicate

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

the class WebEndpointDiscoverer method createOperation.

@Override
protected WebOperation createOperation(EndpointId endpointId, DiscoveredOperationMethod operationMethod, OperationInvoker invoker) {
    String rootPath = PathMapper.getRootPath(this.endpointPathMappers, endpointId);
    WebOperationRequestPredicate requestPredicate = this.requestPredicateFactory.getRequestPredicate(rootPath, operationMethod);
    return new DiscoveredWebOperation(endpointId, operationMethod, invoker, requestPredicate);
}
Also used : WebOperationRequestPredicate(org.springframework.boot.actuate.endpoint.web.WebOperationRequestPredicate)

Example 2 with WebOperationRequestPredicate

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

the class AbstractWebFluxEndpointHandlerMapping method createRequestMappingInfo.

private RequestMappingInfo createRequestMappingInfo(WebOperation operation) {
    WebOperationRequestPredicate predicate = operation.getRequestPredicate();
    String path = this.endpointMapping.createSubPath(predicate.getPath());
    RequestMethod method = RequestMethod.valueOf(predicate.getHttpMethod().name());
    String[] consumes = StringUtils.toStringArray(predicate.getConsumes());
    String[] produces = StringUtils.toStringArray(predicate.getProduces());
    return RequestMappingInfo.paths(path).methods(method).consumes(consumes).produces(produces).build();
}
Also used : WebOperationRequestPredicate(org.springframework.boot.actuate.endpoint.web.WebOperationRequestPredicate) RequestMethod(org.springframework.web.bind.annotation.RequestMethod)

Example 3 with WebOperationRequestPredicate

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

the class AdditionalHealthEndpointPathsWebMvcHandlerMapping method initHandlerMethods.

@Override
protected void initHandlerMethods() {
    for (WebOperation operation : this.endpoint.getOperations()) {
        WebOperationRequestPredicate predicate = operation.getRequestPredicate();
        String matchAllRemainingPathSegmentsVariable = predicate.getMatchAllRemainingPathSegmentsVariable();
        if (matchAllRemainingPathSegmentsVariable != null) {
            for (HealthEndpointGroup group : this.groups) {
                AdditionalHealthEndpointPath additionalPath = group.getAdditionalPath();
                if (additionalPath != null) {
                    registerMapping(this.endpoint, predicate, operation, additionalPath.getValue());
                }
            }
        }
    }
}
Also used : WebOperation(org.springframework.boot.actuate.endpoint.web.WebOperation) WebOperationRequestPredicate(org.springframework.boot.actuate.endpoint.web.WebOperationRequestPredicate) AdditionalHealthEndpointPath(org.springframework.boot.actuate.health.AdditionalHealthEndpointPath) HealthEndpointGroup(org.springframework.boot.actuate.health.HealthEndpointGroup)

Example 4 with WebOperationRequestPredicate

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

the class RequestPredicateFactoryTests method getRequestPredicateReturnsPredicateWithPath.

@Test
void getRequestPredicateReturnsPredicateWithPath() {
    DiscoveredOperationMethod operationMethod = getDiscoveredOperationMethod(ValidSelectors.class);
    WebOperationRequestPredicate requestPredicate = this.factory.getRequestPredicate(this.rootPath, operationMethod);
    assertThat(requestPredicate.getPath()).isEqualTo("/root/{one}/{*two}");
}
Also used : WebOperationRequestPredicate(org.springframework.boot.actuate.endpoint.web.WebOperationRequestPredicate) DiscoveredOperationMethod(org.springframework.boot.actuate.endpoint.annotation.DiscoveredOperationMethod) Test(org.junit.jupiter.api.Test)

Example 5 with WebOperationRequestPredicate

use of org.springframework.boot.actuate.endpoint.web.WebOperationRequestPredicate 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

WebOperationRequestPredicate (org.springframework.boot.actuate.endpoint.web.WebOperationRequestPredicate)9 Test (org.junit.jupiter.api.Test)2 DiscoveredOperationMethod (org.springframework.boot.actuate.endpoint.annotation.DiscoveredOperationMethod)2 WebOperation (org.springframework.boot.actuate.endpoint.web.WebOperation)2 AdditionalHealthEndpointPath (org.springframework.boot.actuate.health.AdditionalHealthEndpointPath)2 HealthEndpointGroup (org.springframework.boot.actuate.health.HealthEndpointGroup)2 RequestMethod (org.springframework.web.bind.annotation.RequestMethod)2 Method (java.lang.reflect.Method)1 Parameter (java.lang.reflect.Parameter)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 EndpointId (org.springframework.boot.actuate.endpoint.EndpointId)1 ExposableWebEndpoint (org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint)1 WebEndpointHttpMethod (org.springframework.boot.actuate.endpoint.web.WebEndpointHttpMethod)1 RequestMappingInfo (org.springframework.web.reactive.result.method.RequestMappingInfo)1