Search in sources :

Example 1 with CompactPathRule

use of org.eclipse.jetty.rewrite.handler.CompactPathRule in project jetty.project by eclipse.

the class RewriteServer method main.

public static void main(String[] args) throws Exception {
    Server server = new Server(8080);
    HttpConfiguration config = server.getConnectors()[0].getConnectionFactory(HttpConnectionFactory.class).getHttpConfiguration();
    RewriteCustomizer rewrite = new RewriteCustomizer();
    config.addCustomizer(rewrite);
    rewrite.addRule(new CompactPathRule());
    rewrite.addRule(new RewriteRegexRule("(.*)foo(.*)", "$1FOO$2"));
    ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
    context.setContextPath("/");
    server.setHandler(context);
    context.addServlet(DumpServlet.class, "/*");
    server.start();
    server.join();
}
Also used : CompactPathRule(org.eclipse.jetty.rewrite.handler.CompactPathRule) Server(org.eclipse.jetty.server.Server) HttpConnectionFactory(org.eclipse.jetty.server.HttpConnectionFactory) RewriteRegexRule(org.eclipse.jetty.rewrite.handler.RewriteRegexRule) RewriteCustomizer(org.eclipse.jetty.rewrite.RewriteCustomizer) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler)

Aggregations

RewriteCustomizer (org.eclipse.jetty.rewrite.RewriteCustomizer)1 CompactPathRule (org.eclipse.jetty.rewrite.handler.CompactPathRule)1 RewriteRegexRule (org.eclipse.jetty.rewrite.handler.RewriteRegexRule)1 HttpConfiguration (org.eclipse.jetty.server.HttpConfiguration)1 HttpConnectionFactory (org.eclipse.jetty.server.HttpConnectionFactory)1 Server (org.eclipse.jetty.server.Server)1 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)1