use of io.gravitee.gateway.policy.PolicyChainResolver in project gravitee-gateway by gravitee-io.
the class ApiReactorHandler method afterPropertiesSet.
@Override
public void afterPropertiesSet() {
contextPath = reactable().contextPath() + '/';
apiPolicyResolver = new ApiPolicyChainResolver();
PolicyChainResolver securityPolicyResolver = new SecurityPolicyChainResolver();
PolicyChainResolver planPolicyResolver = new PlanPolicyChainResolver();
policyResolvers = new ArrayList<PolicyChainResolver>() {
{
applicationContext.getAutowireCapableBeanFactory().autowireBean(securityPolicyResolver);
applicationContext.getAutowireCapableBeanFactory().autowireBean(planPolicyResolver);
applicationContext.getAutowireCapableBeanFactory().autowireBean(apiPolicyResolver);
add(securityPolicyResolver);
add(planPolicyResolver);
add(apiPolicyResolver);
}
};
}
use of io.gravitee.gateway.policy.PolicyChainResolver 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));
}
}
Aggregations