I’m developing a REST service that intercepts every call. The idea is to validate if something is sent on the header like a userid or a token. If it’s not present then send a 403. For that I’m overriding preProcess.
This is all done but what I can’t figure out is how to send a value from the interceptor to the method.
The idea of implementing an intercetpor was to do this for every method so I didn’t need to add @HeaderParam in every method but I still need the header information on the methods.
How can I do this?
You might want to use
@Context HttpHeaders headers
directly in your class and reuse the information in every method.
You can also derive your resource classes from a superclass where you put that annotation. This way many resource classes can share the same behaviour.