Java Code Examples for org.eclipse.jetty.server.handler.gzip.GzipHandler#setMinGzipSize()
The following examples show how to use
org.eclipse.jetty.server.handler.gzip.GzipHandler#setMinGzipSize() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HttpServer.java From heroic with Apache License 2.0 | 5 votes |
private HandlerCollection setupHandler() throws Exception { final ResourceConfig resourceConfig = setupResourceConfig(); final ServletContainer servlet = new ServletContainer(resourceConfig); final ServletHolder jerseyServlet = new ServletHolder(servlet); // Initialize and register Jersey ServletContainer jerseyServlet.setInitOrder(1); // statically provide injector to jersey application. final ServletContextHandler context = new ServletContextHandler(ServletContextHandler.NO_SESSIONS); context.setContextPath("/"); GzipHandler gzip = new GzipHandler(); gzip.setIncludedMethods("POST"); gzip.setMinGzipSize(860); gzip.setIncludedMimeTypes("application/json"); context.setGzipHandler(gzip); context.addServlet(jerseyServlet, "/*"); context.addFilter(new FilterHolder(new ShutdownFilter(stopping, mapper)), "/*", null); context.setErrorHandler(new JettyJSONErrorHandler(mapper)); final RequestLogHandler requestLogHandler = new RequestLogHandler(); requestLogHandler.setRequestLog(new Slf4jRequestLog()); final RewriteHandler rewrite = new RewriteHandler(); makeRewriteRules(rewrite); final HandlerCollection handlers = new HandlerCollection(); handlers.setHandlers(new Handler[]{rewrite, context, requestLogHandler}); return handlers; }