Hi all,

[EMAIL PROTECTED] wrote:
Thierry Boileau <[EMAIL PROTECTED]> wrote on 07/16/2008 04:32:30 AM:
1) to our minds, the routes "/foo" and "/foo/" identify two separate resources. Mostly because this has an impact on relative URIs. When we encountered this kind of issue when developping the o.r.Directory, we decided to addressed it by doign a redirection (redirection to the URI having the training "/").

Hi, Thierry-

Thanks for taking the time to respond to this. Can you explain the circumstances under which "/foo" and "/foo/" would refer to different resources? This seems non-intuitive to me, in terms of what I understand about ROA and REST, and in common usage on the Web, where the non-slash URI frequently, silently redirects to the trailing-slash-uri. I think of it as just a user-friendly convenience I'm offering to my clients: if one of them forgets a trailing slash, it's still clear to me what they intended, and rather than giving them a 404, I can send back a 303.


That's always the case. "http://example.org/foo"; and "http://example.org/foo/"; are two distinct URIs.

Apache Httpd has a module for this [1] which is activated by default. Basically, what's almost invisible is that if you point your browser to an Apache server at "http://example.org/foo"; (where "foo" is a directory), there's an immediate 302 response redirecting the browser to "http://example.org/foo/";. The only case where it's equivalent is the case where the trailing slash would be positioned immediately after the host name.

I agree it would be good to have such a mechanism in Restlet, but the problem isn't specific to Restlet.
A good Restlet-based use-case (if you try to click on the links) is this:
(1) http://www.restlet.org/documentation/1.1
and
(2) http://www.restlet.org/documentation/1.1/


One of the main points of REST is that the client should be guided from one resource to another using the hypermedia (in simpler terms, the <a href="..." /> links or equivalent), so if you get the entry point right, the resources that follow should be fine too (just make sure there's a trailing slash in the links your resource provide). Of course, the tricky case is the case where the entry point isn't right (see link (1) above), in which case the relative URLs this page leads to are incorrect. This sort of mistake is easy to make, especially with browsers that assist you when you start typing an address in the location bar. Having a routing mechanism that would make it possible to turn on the feature as implemented for Directory for other things than directories would be useful indeed. To solve this at the moment, I make sure the users start using the system via a correct URI; all the subsequent URIs they get have the appropriate trailing slashes, since the representation that lead them to these other resources have been generated accordingly.


Best wishes,

Bruno.

[1] http://httpd.apache.org/docs/2.2/mod/mod_dir.html

Reply via email to