Search in sources :

Example 6 with WebOperationRequestPredicate

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

the class RequestPredicateFactory method getRequestPredicate.

WebOperationRequestPredicate getRequestPredicate(String rootPath, DiscoveredOperationMethod operationMethod) {
    Method method = operationMethod.getMethod();
    Parameter[] selectorParameters = Arrays.stream(method.getParameters()).filter(this::hasSelector).toArray(Parameter[]::new);
    Parameter allRemainingPathSegmentsParameter = getAllRemainingPathSegmentsParameter(selectorParameters);
    String path = getPath(rootPath, selectorParameters, allRemainingPathSegmentsParameter != null);
    WebEndpointHttpMethod httpMethod = determineHttpMethod(operationMethod.getOperationType());
    Collection<String> consumes = getConsumes(httpMethod, method);
    Collection<String> produces = getProduces(operationMethod, method);
    return new WebOperationRequestPredicate(path, httpMethod, consumes, produces);
}
Also used : WebOperationRequestPredicate(org.springframework.boot.actuate.endpoint.web.WebOperationRequestPredicate) Parameter(java.lang.reflect.Parameter) DiscoveredOperationMethod(org.springframework.boot.actuate.endpoint.annotation.DiscoveredOperationMethod) WebEndpointHttpMethod(org.springframework.boot.actuate.endpoint.web.WebEndpointHttpMethod) Method(java.lang.reflect.Method) WebEndpointHttpMethod(org.springframework.boot.actuate.endpoint.web.WebEndpointHttpMethod)

Example 7 with WebOperationRequestPredicate

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

the class AdditionalHealthEndpointPathsWebFluxHandlerMapping 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) {
                    RequestMappingInfo requestMappingInfo = getRequestMappingInfo(operation, additionalPath.getValue());
                    registerReadMapping(requestMappingInfo, this.endpoint, operation);
                }
            }
        }
    }
}
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) RequestMappingInfo(org.springframework.web.reactive.result.method.RequestMappingInfo) HealthEndpointGroup(org.springframework.boot.actuate.health.HealthEndpointGroup)

Example 8 with WebOperationRequestPredicate

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

the class AdditionalHealthEndpointPathsWebFluxHandlerMapping method getRequestMappingInfo.

private RequestMappingInfo getRequestMappingInfo(WebOperation operation, String additionalPath) {
    WebOperationRequestPredicate predicate = operation.getRequestPredicate();
    String path = this.endpointMapping.createSubPath(additionalPath);
    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 9 with WebOperationRequestPredicate

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

the class AbstractWebMvcEndpointHandlerMapping method registerMappingForOperation.

private void registerMappingForOperation(ExposableWebEndpoint endpoint, WebOperation operation) {
    WebOperationRequestPredicate predicate = operation.getRequestPredicate();
    String path = predicate.getPath();
    String matchAllRemainingPathSegmentsVariable = predicate.getMatchAllRemainingPathSegmentsVariable();
    if (matchAllRemainingPathSegmentsVariable != null) {
        path = path.replace("{*" + matchAllRemainingPathSegmentsVariable + "}", "**");
    }
    registerMapping(endpoint, predicate, operation, path);
}
Also used : WebOperationRequestPredicate(org.springframework.boot.actuate.endpoint.web.WebOperationRequestPredicate)

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