Hi,
I am trying to make a gzipped response in a Neo4j unmanaged extension. I found this example: http://www.codingpedia.org/ama/how-to-compress-responses-in-java-rest-api-with-gzip-and-jersey/
I tried to add this WriterInterceptor:
@Provider
@Compress
public class GZIPWriterInterceptor implements WriterInterceptor {
@Override
public void aroundWriteTo(WriterInterceptorContext context)
throws IOException, WebApplicationException {
MultivaluedMap<String,Object> headers = context.getHeaders();
headers.add("Content-Encoding", "gzip");
final OutputStream outputStream = context.getOutputStream();
context.setOutputStream(new GZIPOutputStream(outputStream));
context.proceed();
}
}
And this annotation:
@NameBinding
@Retention(RetentionPolicy.RUNTIME)
public @interface Compress {
}
And in my resource I use it like this:
@GET
@Path("/users")
@Produces(MediaType.APPLICATION_JSON)
@Compress
public List<User> getUsers() {
return factory.getUserService(graphDb).getUsers();
}
However the WriterInterceptor is never called, why? How can I make my response gzipped?
I want to solve this inside my unmanaged plugin and solutions where the response is gzipped in a proxy outside of Neo4j is not an alternative.