[gateway] Response templates improvement #2208
It would be great if you will add a failure thats using response templates keys into gravitee-policy-oauth2.
And finally, response templates can be more flexible if you add the ability to set them by http-code. The simple example to illustrate this idia is modify the beggining of ResponseTemplateBasedFailureProcessor.handleFailure method like this:
It's not able to modify gravitee-policy-oauth2 failures
Response templates mechanism can be more flexible and universal
Thanks for your feedback.
Response template is not yet developed for all the policies, but you're right, it must be provided for most of them, and mainly oauth2 and JWT (as it is done with apikey policy).
About applying response template per http status code, I don't know if it makes sense since the same http status code may represent multiple and distinct errors (for example, 400 for a bad request, or 401 for unauthorized).
Perhaps you can help and contribute on this?
Yes, sure, we can modify oauth2 and jwt policy and make pull request according CONTRIBUTING.adoc
Also we can modify all ...failWith(PolicyResult.failure... in gateway component. It occurs in the code only 8 times. It gives the ability to modify response in cases like for example in SecurityPolicyChainResolver.class [line:57]
Applying response template per http status code may be usefull then, for example, there is a need to transform all responses with particular code to one template. If I think up other useful example I will leave the comment here )