Swaraj Shekhar Swaraj Shekhar - 3 months ago 8
reST (reStructuredText) Question

Send response after rest authentication fails

I have over-ridden ContainerRequestFilters by class A and ContainerResponseFilters by Class B.

Now whenever there is a rest call, class A gets the request first and then it goes to another class, Class C.

The flow is, request comes to Class A, then it goes to class C and finally to Class B.

Now when I see that something is not good and I need to send a response, how can I do it from class A. I need to bypass class C.

Answer

Throw exception and catch it in your main class or using ExceptionMapper - Return exception from JAX-RS Rest Service as JSON.