Search code examples
javarestlet

Restlet routing does not work with Directory in the route?


I'm having a bit of trouble making these Restlet Server Resources to work:

  private static final String ROOT_URI = "/rest/";
  @Override
  public Restlet createInboundRoot() {
    Router router = new Router(getContext());
    Directory directory = new Directory(getContext(), "war:///doc");
    directory.setIndexName("app.html");
    router.attach(ROOT_URI + "files", GaeFilesServerResource.class);
    router.attach(ROOT_URI + "files/{file_id}", GaeFileServerResource.class);
    router.attach("/gwtapp/", directory); // This is the only one that works
    router.attach("/", RootServerResource.class);
    return router;
  }

As described in the comment the route /gwtapp/ is the only one that works. Accessing http://localhost:8080/gwtapp/ forward to http://localhost:8080/gwtapp/app.html which is correct.

The question is:

I wonder why those under / and /rest/ would not work in this case?


Solution

  • Solution was to attach:

    router.attachDefault(RootServerResource.class);
    

    instead.