use of io.dropwizard.jetty.BiDiGzipHandler in project airpal by airbnb.
the class AirpalApplicationBase method run.
@Override
public void run(T config, Environment environment) throws Exception {
this.injector = Guice.createInjector(Stage.PRODUCTION, getModules(config, environment));
System.setProperty(IO_BUFFER_SIZE, String.valueOf(config.getBufferSize().toBytes()));
environment.healthChecks().register("presto", injector.getInstance(PrestoHealthCheck.class));
environment.jersey().register(injector.getInstance(ExecuteResource.class));
environment.jersey().register(injector.getInstance(QueryResource.class));
environment.jersey().register(injector.getInstance(QueriesResource.class));
environment.jersey().register(injector.getInstance(UserResource.class));
environment.jersey().register(injector.getInstance(UsersResource.class));
environment.jersey().register(injector.getInstance(TablesResource.class));
environment.jersey().register(injector.getInstance(HealthResource.class));
environment.jersey().register(injector.getInstance(PingResource.class));
environment.jersey().register(injector.getInstance(SessionResource.class));
environment.jersey().register(injector.getInstance(FilesResource.class));
environment.jersey().register(injector.getInstance(ResultsPreviewResource.class));
environment.jersey().register(injector.getInstance(S3FilesResource.class));
environment.jersey().register(injector.getInstance(AirpalUserFactory.class));
// Setup SSE (Server Sent Events)
ServletRegistration.Dynamic sseServlet = environment.servlets().addServlet("updates", injector.getInstance(SSEEventSourceServlet.class));
sseServlet.setAsyncSupported(true);
sseServlet.addMapping("/api/updates/subscribe");
// Disable GZIP content encoding for SSE endpoints
environment.lifecycle().addServerLifecycleListener(server -> {
for (Handler handler : server.getChildHandlersByClass(BiDiGzipHandler.class)) {
((BiDiGzipHandler) handler).addExcludedMimeTypes(SERVER_SENT_EVENTS);
}
});
}
Aggregations