HealthCheckRegistry healthChecks) {
configureSessionsAndSecurity(handler, server);
handler.setServer(server);
handler.getServletContext().setAttribute(MetricsServlet.METRICS_REGISTRY, metrics);
handler.getServletContext().setAttribute(HealthCheckServlet.HEALTH_CHECK_REGISTRY, healthChecks);
handler.addServlet(new NonblockingServletHolder(new AdminServlet()), "/*");
handler.addFilter(AllowedMethodsFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST))
.setInitParameter(AllowedMethodsFilter.ALLOWED_METHODS_PARAM, Joiner.on(',').join(allowedMethods));
return handler;
}