Prev | Current Page 286 | Next

Brad Ediger

"Advanced Rails"

In either case, the URI of the POST is that of the object??™s container or
parent. The RFC draws an analogy of a directory structure; to create or update an
object, you POST to its containing ???directory.???
To create a resource, its representation is sent via POST to a URI responsible for creating
resources of that type. If the request for creation succeeds, the server issues a
redirect via the Location header pointing to the URI of the created resource.
When annotating a resource, the POST URI is that of the resource to be annotated
(the ???parent??? of the entity being sent). This is different from a PUT request in that the
resource being POSTed to is not being updated with a new representation, but rather
annotated with additional information.
Resources
The most foundational concept of REST is the resource. The most general definition
of a resource is something with identity. It really is as simple as that. In popular usage,
the term ???resource??? usually means something that is network-addressable on the
Internet, and it is with these types of resources that we will concern ourselves. But a
resource can really be anything, tangible or intangible, that can be named. As RFC
2396 explains:*
A resource can be anything that has identity. Familiar examples include an electronic
document, an image, a service (e.g., ???today??™s weather report for Los Angeles???), and a
collection of other resources.


Pages:
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298