3

we are working on creating a RESTFul service, and trying to decide on the URL path format.

we have urn for uniquely identify a resource throughout the organization, and we are building the Rest service to service that resource in the format the requester is looking for via http content negotiation.

my question is that how should we form the path of the url for the service, which one make more sense.

http://{domain}/{somethinghere}/{full urn string}
or
http://{domain}/{somethinghere}/{urn-part-1}/{urn-part-2}/{urn-part-3}
Darrel Miller
  • 139,164
  • 32
  • 194
  • 243
Eatdoku
  • 6,569
  • 13
  • 63
  • 98

1 Answers1

3

I have the same question too!... IMHO, I would use the full urn string,

http://{domain}/{somethinghere}/{full urn string}

It's elegant, semi-legal, and has a user-friendly feature of making it easier to copy-and-paste URN strings into your URL. Here's some of the homework I've done:

There is an old experimental RFC 2169 which suggests putting in the full urn string, and not %quoting the the colons (:). This is clean and elegant... And there are examples of colons in the wild e.g.,

http://en.wikipedia.org/wiki/Talk:Buckminster_Fuller

One of my fears (can anyone confirm or reject this?) is that some browsers, servers, frameworks, or tools may try to %quote or otherwise choke on a colon because of various assumptions that they may make about what a colon represents.

Neither RFC 1630 nor other RFCs make it clear whether a colon may be used in a path of the http scheme or not. There is a caveat however! The placement of a colon is important in determining whether or not a URL is absolute (and this is specified under the section "Partial (relative) form" in RFC 1630). If a colon appears before a slash (/), then the URL is absolute. (N.B. the colon is referred to as a "reserved" delimiter in the RFCs, but the intended reserved use of it is clear and does not rule out use in paths.)

I'd love to here more ideas about this... (and not just taking the easy cop-out of slash-encoding everything, as that is not as elegant).

Community
  • 1
  • 1
David Baird
  • 772
  • 8
  • 13
  • i tried the first way, having the ":" in the url, but iis rejects it. it is allowed in the querystring but not part of the path. that's my finding. it might be because we are using an extensionless url. We are currently spliting it apart in the url. – Eatdoku Sep 08 '11 at 17:38
  • That is my fear... the inconsistent handling of ':' is very unfortunate because it forces an incompatibility between URNs and URLs. I would like to see this particular issue of ':' clarified so that we may see more URNs embedded inside of URLs. In the mean time, I guess you could settle with: http://{domain}/{somethinghere}/?urn={full urn string} – David Baird Sep 11 '11 at 18:10
  • 3
    ...and your idea of using '/' delimiters is not a bad idea, if the ?urn={full urn string} is unsuitable. I have considered doing '/' delimiting myself... but for the time being I've been hacking my tools together to force supporting of ':' because of my perfectionist nature! – David Baird Sep 11 '11 at 18:21