private HandlerCollection createHandlers() { final WebAppContext webApp = new WebAppContext(); webApp.setContextPath(contextPath); webApp.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false"); webApp.getSessionHandler().setMaxInactiveInterval(sessionTimeout * 60); // GZIP handler final GzipHandler gzipHandler = new GzipHandler(); gzipHandler.addIncludedMimeTypes("text/html", "text/xml", "text/css", "text/plain", "text/javascript", "application/javascript", "application/json", "application/xml"); gzipHandler.setIncludedMethods("GET", "POST"); gzipHandler.setCompressionLevel(9); gzipHandler.setHandler(webApp); if (Strings.isNullOrEmpty(webAppLocation)) { webApp.setWar(getShadedWarUrl()); } else { webApp.setWar(webAppLocation); } // Request log handler final RequestLogHandler log = new RequestLogHandler(); log.setRequestLog(createRequestLog()); // Redirect root context handler MovedContextHandler rootRedirect = new MovedContextHandler(); rootRedirect.setContextPath("/"); rootRedirect.setNewContextURL(contextPath); rootRedirect.setPermanent(true); // Put rootRedirect at the end! return new HandlerCollection(log, gzipHandler, rootRedirect); }
@Override public void customize(final Server server) { final HandlerCollection handlers = new HandlerCollection(); final MovedContextHandler movedContextHandler = new MovedContextHandler(); movedContextHandler.setContextPath("/"); movedContextHandler.setNewContextURL(this.root); movedContextHandler.setPermanent(true); movedContextHandler.setDiscardPathInfo(false); movedContextHandler.setDiscardQuery(false); movedContextHandler.setVirtualHosts(new String[]{this.host}); handlers.addHandler(movedContextHandler); asList(server.getHandlers()).forEach(handlers::addHandler); server.setHandler(handlers); } }
@Override public void customize(final Server server) { final HandlerCollection handlers = new HandlerCollection(); final MovedContextHandler movedContextHandler = new MovedContextHandler(); movedContextHandler.setContextPath("/"); movedContextHandler.setNewContextURL(this.root); movedContextHandler.setPermanent(true); movedContextHandler.setDiscardPathInfo(false); movedContextHandler.setDiscardQuery(false); movedContextHandler.setVirtualHosts(new String[]{this.host}); handlers.addHandler(movedContextHandler); asList(server.getHandlers()).forEach(handlers::addHandler); server.setHandler(handlers); } }
private static ContextHandlerCollection prepareContexts() { MovedContextHandler handler = new MovedContextHandler(); handler.setContextPath("/membership"); handler.setNewContextURL("/#/membership"); handler.setPermanent(true); handler.setDiscardPathInfo(false); handler.setDiscardQuery(false); WebAppContext webAppContext = new WebAppContext(); webAppContext.setServer(server); webAppContext.setContextPath("/"); webAppContext.setWar("src/main/webapp"); ContextHandlerCollection contexts = new ContextHandlerCollection(); contexts.setHandlers(new Handler[] { handler, webAppContext }); return contexts; }