Skip to main content

Encoders in REST servers

The @Rest(encoders) annotation can be used to associate character encoders with a servlet class. Encoders can be used to enable various kinds of compression (e.g. gzip) on requests and responses based on the request Accept-Encoding and Content-Encoding headers.

For the encoder API itself, see Encoders.

Example​

import org.apache.juneau.marshall.encoders.*;
import org.apache.juneau.rest.server.*;
import org.apache.juneau.rest.server.servlet.*;

// Servlet with automated support for GZIP compression
@Rest(encoders={GzipEncoder.class})
public class MyRestServlet extends BasicRestServlet {}

Options​

Juneau defines the following encoders out-of-the-box:

GzipEncoderIdentityEncoder

See also​