Search in sources :

Example 1 with StreamType

use of io.gravitee.gateway.policy.StreamType in project gravitee-gateway by gravitee-io.

the class ApiPolicyChainResolver method calculate.

@Override
protected List<Policy> calculate(StreamType streamType, Request request, Response response, ExecutionContext executionContext) {
    // Resolve the "configured" path according to the inbound request
    Path path = pathResolver.resolve(request.path());
    executionContext.setAttribute(ExecutionContext.ATTR_RESOLVED_PATH, path.getResolvedPath());
    return path.getRules().stream().filter(rule -> rule.isEnabled() && rule.getMethods().contains(request.method())).map(rule -> create(streamType, rule.getPolicy().getName(), rule.getPolicy().getConfiguration())).filter(Objects::nonNull).collect(Collectors.toList());
}
Also used : Path(io.gravitee.gateway.handlers.api.path.Path) Objects(java.util.Objects) Policy(io.gravitee.gateway.policy.Policy) List(java.util.List) Response(io.gravitee.gateway.api.Response) Path(io.gravitee.gateway.handlers.api.path.Path) StreamType(io.gravitee.gateway.policy.StreamType) ExecutionContext(io.gravitee.gateway.api.ExecutionContext) Request(io.gravitee.gateway.api.Request) AbstractPolicyChainResolver(io.gravitee.gateway.policy.AbstractPolicyChainResolver) PathResolver(io.gravitee.gateway.handlers.api.path.PathResolver) Autowired(org.springframework.beans.factory.annotation.Autowired) Collectors(java.util.stream.Collectors)

Aggregations

ExecutionContext (io.gravitee.gateway.api.ExecutionContext)1 Request (io.gravitee.gateway.api.Request)1 Response (io.gravitee.gateway.api.Response)1 Path (io.gravitee.gateway.handlers.api.path.Path)1 PathResolver (io.gravitee.gateway.handlers.api.path.PathResolver)1 AbstractPolicyChainResolver (io.gravitee.gateway.policy.AbstractPolicyChainResolver)1 Policy (io.gravitee.gateway.policy.Policy)1 StreamType (io.gravitee.gateway.policy.StreamType)1 List (java.util.List)1 Objects (java.util.Objects)1 Collectors (java.util.stream.Collectors)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1