Prev | Current Page 292 | Next

Brad Ediger

"Advanced Rails"

A primary
obstacle to adoption is the dearth of ways to represent semantic metadata in hypermedia
at the moment. RDF is gaining currency in this field, but there are still few wellknown
best practices as to how to encode relationships between resources within their
representations.
194 | Chapter 7: REST, Resources, and Web Services

Order #124


Items:





But a request to the same resource with a different URI, at /orders/124.xml, might
result in a more easily machine-readable XML version:


Office Chair, Medium
Ergonomic Keyboard


The JavaScript representation at /orders/124.js might use JSON:
{"order": {
"id": 124,
"items": [
{"id": 1, "href": "/orders/124/items/1",
"description": "Office Chair, Medium"},
{"id": 2, "href": "/orders/124/items/2",
"description": "Ergonomic Keyboard"}]
}}
Changing content types based on URI extensions is nice and easy, and it plays well
with the way we traditionally expect the Web to work. Among other things, it makes
the URIs look like filenames again, and behave somewhat like filesystem paths.


Pages:
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304