Restlet - serving static content

Using Restlet I needed to serve simple static content in the same context as my web service. I configured the component with Directory, but during testing, I found that it will only serve as "index.html", everything else leads to 404.

router.attach("/", new Directory(context, new Reference(baseRef, "./content"));

So ... http: // service and http: //service/index.html both work,

but http: //service/other.html gives me 404

Can anyone shed some light on this? I want any file in a directory. / content was available.

PS: Ultimately, I plan to use a reverse proxy server and serve all the static data from another web server, but for now I need it to work as it is.

+3
source share
2 answers

Ok, I get the question. In fact, Restlete appears to route requests based on the prefix, but does not handle the long corresponding prefix correctly, it also ignores file extensions.

So, for example, if I had a resource attached to "/ other" ... and a directory on "/". And I ask /other.html what actually happens, I get the resource "/ other". (Extension ignored?), Not a static file from a directory, as I expected.

If Ainon knows why this is, or how to change it, I would love to know. It doesn’t matter, just for testing. I think we will host apache or nginx before this in production.

+2
source

Restlet "Template.MODE_STARTS_WITH". Router , router.setMatchingMode(Template.MODE_EQUALS). attach. setMatchingMode.

+2

Source: https://habr.com/ru/post/1697688/


All Articles