How to mount all but some URLs to a single page?

115 views Asked by At

I'm working on a single page application and want to mount arbitrary URLs my home page (Index.class), e.g.

/index
/home
/foo
/somethingelse
...

But some URLs should not be handled, to deliver static assets and access the REST api e.g.:

/api
/images
/css

So my question is, how to configure Wicket to route all but some special URLs to a single page. I guess I have to implement a custom RequestMapper and delegeate to the default one. Maybe something like this:

public class WicketApplication extends WebApplication {

    @Override
    public Class<? extends WebPage> getHomePage() {
        return Index.class;
    }

    @Override
    public void init() {

        mount(new IRequestMapper() {
           // routing logic goes here
        });

        mountPage("/${page}", Index.class);
    }
}

additionally, I defined ${page} as an URL parameter to inject some config dynamically.

1

There are 1 answers

1
Andrea Del Bene On

I don't have the entire picture of your code, but you could simply mount Wicket application to a different path (ex: /myapp) and use another one for static/REST resources.