@Test
 public void loadsServerPushConfig() throws Exception {
   final ServerPushFilterFactory serverPush = http.getServerPush();
   assertThat(serverPush.isEnabled()).isTrue();
   assertThat(serverPush.getRefererHosts()).contains("dropwizard.io");
   assertThat(serverPush.getRefererPorts()).contains(8445);
 }
Пример #2
0
 protected Handler createAppServlet(
     Server server,
     JerseyEnvironment jersey,
     ObjectMapper objectMapper,
     Validator validator,
     MutableServletContextHandler handler,
     @Nullable Servlet jerseyContainer,
     MetricRegistry metricRegistry) {
   configureSessionsAndSecurity(handler, server);
   handler
       .addFilter(AllowedMethodsFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST))
       .setInitParameter(
           AllowedMethodsFilter.ALLOWED_METHODS_PARAM, Joiner.on(',').join(allowedMethods));
   handler.addFilter(ThreadNameFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
   serverPush.addFilter(handler);
   if (jerseyContainer != null) {
     if (jerseyRootPath.isPresent()) {
       jersey.setUrlPattern(jerseyRootPath.get());
     }
     jersey.register(new JacksonMessageBodyProvider(objectMapper));
     jersey.register(new HibernateValidationFeature(validator));
     if (registerDefaultExceptionMappers == null || registerDefaultExceptionMappers) {
       jersey.register(new LoggingExceptionMapper<Throwable>() {});
       jersey.register(new JerseyViolationExceptionMapper());
       jersey.register(new JsonProcessingExceptionMapper());
       jersey.register(new EarlyEofExceptionMapper());
     }
     handler.addServlet(new NonblockingServletHolder(jerseyContainer), jersey.getUrlPattern());
   }
   final InstrumentedHandler instrumented = new InstrumentedHandler(metricRegistry);
   instrumented.setServer(server);
   instrumented.setHandler(handler);
   return instrumented;
 }