Jerome,

Aha, thanks for that clarification. If I understand things correctly, I can adopt HTTP/WebDAV collection principles by using a trailing slash in my registrations?

Hello "resource" :
container.getDefaultHost().attach("/hello", restlet);


Versus Hello "collection":
container.getDefaultHost().attach("/hello/", myRestlet);

I guess the only last thing needed is a redirect handler so that "/ hello" requests get redirected to "/hello/". So if all those assumptions are correct, then it looks like this framework can be made WebDAV-friendly, with a bit of manual configuration.

Thanks,
David



On Dec 28, 2006, at 6:42 AM, Jerome Louvel wrote:


David,

Thanks for the feed-back, you are bringing up important points that I need
to clarify.

First, I encourage you to upgrade to RC1 as the API in this area changed:
 - Request.baseRef -> Request.resourceRef.baseRef
 - Request.relativePart -> Request.resourceRef.remainingPart
Note that there is also a Reference.relativePart property.

Now, it is important to realize that the routing done via Router and Route
classes is working on URIs at the string level. Each time the route is
accepted and followed, the base URI (Request.resourceRef.baseRef) related to the resource URI (Request.resourceRef) is updated. It stricly contains the
characters match by the URI pattern of the latest route.

So, if your URI pattern didn't match the trailing slash, the base URI won't
contain a trailing slash. If you need to use the base URI to compute
relative URIs, then I suggest that you change your URI pattern to include a
slash at the end.

Example:
 - resource URI: http://<server:port>/persons/1
 - virtual host: http://<server:port>

If your URI pattern is "/persons":
 - base URI: "/persons"
 - remaining part: "/1"
 - relative part: "persons/1"

If your URI pattern is "/persons/":
 - base URI: "/persons/"
 - remaining part: "1"
 - relative part: "1"

Let me know if you need more clarifications.

Best regards,
Jerome

-----Original Message-----
From : David Rauschenbach [mailto:[EMAIL PROTECTED]
Date : mercredi 27 décembre 2006 17:32
To : [EMAIL PROTECTED]
Object : Restlet base URI versus relative path

Hello,

I've been using the restlet API and Noelios container for a
few weeks
now, with satisfactory results. This is fine work, and a useful
abstraction.

It seems wrong to me that Request.getBaseRef() does not return a
trailing slash, and especially wrong that Request.getResourceRef()
begins with a slash. This concept is in particular dis-harmony with
WebDAV, which is the extension of the HTTP spec that extends it for
read/write operations.

In WebDAV, as well as in industry current-best-practices such as
default Apache configurations, trailing shashes are formalized to
mean "resource collection", such as directories. The same goes for
Rails and ActiveResource/REST, where a relative path of person with
id=1 should be relativePart="1" and baseURI="http://<server:port>/
persons/" or whatever, the case of a url "http://<server:port>/
persons/1".

David


Reply via email to