2

I have a Restlet application already working that accepts JSON and returns JSON entity as response.

I'm trying to understand how I can compress the JSON entity that is returned in the response. I did not find any clear example on how to achieve it.

I think I have to put somewhere on the router chain the Encoder/EncoderService classes, but I really don't understand where and how to use them.

Could anybody help me?

emas
  • 668
  • 8
  • 17

1 Answers1

1

After some testing, I got the answer.

Creating a new filter like this

Filter encoder = new Encoder(getContext(), false, true, new EncoderService(true));

inside the createInboundRoot() method of my own Application class did the trick, the client requests were already containing the gzip header needed.

emas
  • 668
  • 8
  • 17