--
You received this message because you are subscribed to the Google Groups "API Craft" group.
To unsubscribe from this group, send email to api-craft+...@googlegroups.com.
Visit this group at http://groups.google.com/group/api-craft?hl=en.
Hi List,I've been struggling with mapping resources with composite keys to a RESTful interface. Maybe some of you have some ideas?Here's a scenario:
You have a huge collection of widgets, and by necessity you've sharded the relational database that stores them into multiple databases. Let's say it's sharded by widget type. Each widget also has its own integer ID. So you essentially have a widget that is identified by a composite key of type and id.
/widgets/:widgetType/:widgetId
Eg /widgets/gears/123
That gives you scope to list all widgets (/widgets/), just all gears (/widgets/gears/) or a single gear.
Regards
Andrew Eddie
These characters are called "reserved" because they may (or may not) be defined as delimiters by the generic syntax, by each scheme-specific syntax, or by the implementation-specific syntax of a URI's dereferencing algorithm.
...
The purpose of reserved characters is to provide a set of delimiting characters that are distinguishable from other data within a URI.
Aside from dot-segments in hierarchical paths, a path segment is considered opaque by the generic syntax. URI producing applications often use the reserved characters allowed in a segment to delimit scheme-specific or dereference-handler-specific subcomponents.
Aside from dot-segments in hierarchical paths, a path segment is considered opaque by the generic syntax. URI producing applications often use the reserved characters allowed in a segment to delimit scheme-specific or dereference-handler-specific subcomponents.Am I misinterpreting the RFC? I've found that ":" is tolerated by some tools and not others; apiary.io understands it if you use the reserved expansion URI Template form (e.g. /widgets/{+key}) of , but for example restify won't route requests to handlers that use it's URI-template-like ":id" syntax if the requests have a colon in them.
3. /widgets/{key of base64-encoded-string of widget_type:widget_id} - like /widgets/[aGVsbG8gdGhlcmUu
[...]
Option 3 works fairly well because it's hiding implementation a bit. You've got a string key, but now you need to base64 decode in order to find your object.
If you Base64 encode the number 959, the result is O/. Of course, this isn't a url-safe value because of the "/", so a url pointing to O/ would not be decoded as O/, but as O (which is the decimal value 14)