I have:
Directory webdir = new Directory(getContext(), "clap://class/webapp");
webdir.setDeeplyAccessible(true);
router.attach("",webdir);
This works when serving all the files in a directory by name.
However, it should serve index.htmlwhen you visit the "/", but it is not. I tried all combinations of paths, additional routers, etc. Etc., And it still does not work.
When you visit "/", you get a 200 response and the type of application content / octet stream. The answer is otherwise empty. getIndexNameon Directory makes me thisindex
I also tried getMetadataService().addExtension("html", MediaType.TEXT_HTML, true);to help him pick up the index.html file, but to no avail, and also set the accept header in the request for text / html.
ETA: this is the same (unresolved) problem described here: http://restlet-discuss.1400322.n2.nabble.com/Serving-static-files-using-Directory-and-CLAP-from-a-jar -td7578543.html
Can anyone help with this? It drives me crazy.
After messing around a bit, I now have a workaround, but I would prefer not to redirect if possible:
Redirector redirector = new Redirector(getContext(), "/index.html", Redirector.MODE_CLIENT_PERMANENT);
TemplateRoute route = router.attach("/",redirector);
route.setMatchingMode(Template.MODE_EQUALS);
source
share