use of io.undertow.predicate.PredicatesHandler in project ice by JBEI.
the class DevelopmentServer method main.
public static void main(String[] args) throws Exception {
DeploymentInfo servletBuilder = Servlets.deployment().setClassLoader(ClassLoader.getSystemClassLoader()).addListener(Servlets.listener(IceServletContextListener.class)).setContextPath("/").setDeploymentName("Inventory for Composable Elements").setResourceManager(new FileResourceManager(new File("src/main/webapp"), 10)).addWelcomePage("index.htm").addServlets(Servlets.servlet("Jersey REST Servlet", ServletContainer.class).addInitParam("jersey.config.server.provider.packages", "org.jbei.ice.services.rest").addInitParam("jersey.config.server.provider.scanning.recursive", "false").addInitParam("javax.ws.rs.Application", "org.jbei.ice.services.rest.multipart.IceApplication").setAsyncSupported(true).setEnabled(true).addMapping("/rest/*"));
// deploy servlet
DeploymentManager manager = Servlets.defaultContainer().addDeployment(servletBuilder);
manager.deploy();
HttpHandler servletHandler = manager.start();
PredicatesHandler handler = Handlers.predicates(PredicatedHandlersParser.parse("path-prefix('search') or " + "path-prefix('folders') or " + "path-prefix('upload') or " + "path-prefix('download') or " + "path-prefix('entry') or path-prefix('admin') and regex('/.+') -> rewrite('/')", ClassLoader.getSystemClassLoader()), servletHandler);
PathHandler path = Handlers.path(Handlers.redirect("/")).addPrefixPath("/", handler);
Undertow server = Undertow.builder().addHttpListener(8080, "localhost").setHandler(path).build();
server.start();
}
Aggregations