Reply To: how do I forward to other apps, etc?

Splash Forums Rewrite Users how do I forward to other apps, etc? Reply To: how do I forward to other apps, etc?

#25992

heyoka
Participant

OK it IS possible! Here’s how:

The router app is set with an empty context path. Rules are set to forward to other apps:

               .addRule()
                .when(Direction.isInbound().and(Path.matches("/b/{path}")))
                .perform(
                     Redirect.temporary("/app/task-a/{path}")
                 )
               .addRule()
                .when(Direction.isInbound().and(Path.matches("/{path}")))
                .perform(
                     Redirect.temporary("/app/task/{path}")
                 )
                .where("path").matches("key1|key2|key3");

Now here’s the tricky part. I want to have a static directory which serves images to my apps. But since the router has an empty context path, all requests go to it. EXCEPT……

Glassfish allows you to set up an alternate docroot (besides the default one which is now inaccessible). You do this by adding it to glassfish-web.xml like this:

<property name="alternatedocroot_1" value="from=/img/* dir=/docroot"/>

When a request comes in, glassfish first checks against alternate docroots. If it finds one, the request is served from there. Otherwise it goes to the application docroot, sees that there is a default app with an empty context path, and hands the request to this app (router).