Hi Serge,
I guess I am ready to give up. All my attempts failed including suggested.
> Actually, just reading API without going through the source code I do not
> see
> how this issue (serving home resource for http://bobcat/ and serving a
> file for
> http://bobcat/file.html) can be solved. For example, something like this
>
> router.setRoutingMode(Router.FIRST);
> router.attach("/files", directory);
> router.attachDefault(directory);
> router.attach("/", HomeResource.class);
The difficulty here is that the URI matching algorithm tries by default to
match the beginning of the remaining URI part. In your case, you have either
"/" or "/file.html" to match, and both of these values match the "/" pattern
as well as the default route.
So we need another way to discriminate between those options. The key is to
change the default template matching mode (MODE_STARTS_WITH) to MODE_EQUALS
like this:
router.attach("/", HomeResource.class).getTemplate().
setMatchingMode(Template.MODE_EQUALS);
router.attachDefault(directory);
This should definitely work! :)
Regards,
Jerome