Search in sources :

Example 1 with RewriteHandler

use of io.undertow.servlet.compat.rewrite.RewriteHandler in project undertow by undertow-io.

the class RewriteTestCase method setup.

@BeforeClass
public static void setup() throws ServletException {
    DeploymentUtils.setupServlet(new ServletExtension() {

        @Override
        public void handleDeployment(DeploymentInfo deploymentInfo, ServletContext servletContext) {
            deploymentInfo.addOuterHandlerChainWrapper(new HandlerWrapper() {

                @Override
                public HttpHandler wrap(HttpHandler handler) {
                    byte[] data = "RewriteRule /foo1 /bar1".getBytes(StandardCharsets.UTF_8);
                    RewriteConfig config = RewriteConfigFactory.build(new ByteArrayInputStream(data));
                    return new RewriteHandler(config, handler);
                }
            });
        }
    }, new ServletInfo("servlet", PathTestServlet.class).addMapping("/"));
}
Also used : ServletInfo(io.undertow.servlet.api.ServletInfo) HttpHandler(io.undertow.server.HttpHandler) ByteArrayInputStream(java.io.ByteArrayInputStream) ServletContext(javax.servlet.ServletContext) RewriteConfig(io.undertow.servlet.compat.rewrite.RewriteConfig) DeploymentInfo(io.undertow.servlet.api.DeploymentInfo) ServletExtension(io.undertow.servlet.ServletExtension) HandlerWrapper(io.undertow.server.HandlerWrapper) RewriteHandler(io.undertow.servlet.compat.rewrite.RewriteHandler) BeforeClass(org.junit.BeforeClass)

Aggregations

HandlerWrapper (io.undertow.server.HandlerWrapper)1 HttpHandler (io.undertow.server.HttpHandler)1 ServletExtension (io.undertow.servlet.ServletExtension)1 DeploymentInfo (io.undertow.servlet.api.DeploymentInfo)1 ServletInfo (io.undertow.servlet.api.ServletInfo)1 RewriteConfig (io.undertow.servlet.compat.rewrite.RewriteConfig)1 RewriteHandler (io.undertow.servlet.compat.rewrite.RewriteHandler)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ServletContext (javax.servlet.ServletContext)1 BeforeClass (org.junit.BeforeClass)1