users@jersey.java.net

[Jersey] Re: How to intercept response and get original entitiy object?

From: Jakub Podlesak <jakub.podlesak_at_oracle.com>
Date: Thu, 22 Aug 2013 11:40:25 +0200

Hi,

Confirmed this should be possible using an interceptor.

You only need to inject e.g. UriInfo (with @Context UriInfo uriInfo)
into your interceptor to get access to the query parameters.

HTH,

~Jakub


On Aug 22, 2013, at 8:48 AM, marceloverdijk_at_gmail.com wrote:

> My resource method is returning a javax.json.JsonObject containing
> data.
>
> I want to intercept this response, and enhance the JsonObject with
> additional data.
>
> Is this possible in an interceptor?
>
>
> The use case is I want to implement "suppress response codes"
> functionality similar to Twitters api.
> If a certain request parameter is present in the api request (e.g.
> ?suppress_response_codes=true) I want to wrap my actual response in
> something like:
> { "status": 200,
> "response": { .. }
> }