Search in sources :

Example 1 with PolicyChainResult

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

the class RequestPolicyChainProcessor method execute.

public void execute(Request request, Response response, ExecutionContext executionContext) {
    if (iterator.hasNext()) {
        PolicyChainResolver policyChainResolver = iterator.next();
        PolicyChain policyChain = policyChainResolver.resolve(StreamType.ON_REQUEST, request, response, executionContext);
        lastPolicyChain = policyChain;
        policyChain.setResultHandler(policyResult -> {
            if (!policyResult.isFailure()) {
                execute(request, response, executionContext);
            } else {
                resultHandler.handle(new PolicyChainResult(lastPolicyChain, policyResult));
            }
        });
        policyChain.setStreamErrorHandler(result -> streamErrorHandler.handle(new PolicyChainResult(lastPolicyChain, result)));
        policyChain.doNext(request, response);
    } else {
        resultHandler.handle(new PolicyChainResult(lastPolicyChain, null));
    }
}
Also used : PolicyChainResult(io.gravitee.gateway.policy.PolicyChainResult) PolicyChainResolver(io.gravitee.gateway.policy.PolicyChainResolver)

Aggregations

PolicyChainResolver (io.gravitee.gateway.policy.PolicyChainResolver)1 PolicyChainResult (io.gravitee.gateway.policy.PolicyChainResult)1