Implementing request message body interceptors

You can use the javax.ws.rs.ext.ReaderInterceptor interface to intercept and manipulate the incoming message body.

The following example illustrates how you can implement ReaderInterceptor to intercept the incoming message in order to unzip the zipped body content:

//Other imports are omitted for brevity import java.util.zip.GZIPInputStream; import javax.ws.rs.WebApplicationException; import javax.ws.rs.ext.Provider; import javax.ws.rs.ext.ReaderInterceptor; import javax.ws.rs.ext.ReaderInterceptorContext; @Provider public class JAXRSReaderInterceptor implements ReaderInterceptor { @Override public Object aroundReadFrom(ReaderInterceptorContext context) throws IOException, WebApplicationException ...

Get RESTful Java Web Services - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.