However, all of this fuss was but a symptom of the real problem. The problem was
not so much that GET links performed actions; it was that HTTPwas being used
improperly. The contract between clients and servers had been broken. So, when all
of the GET /people/delete/123 actions became POST /people/delete/123, it was an
improvement, but not by much, as POST is not terribly relevant to a ???delete person???
action. A more RESTful design would involve an action such as DELETE /people/123.
What Is REST? | 189
PUT
The PUT method updates a resource with the representation provided in the body of
the PUT request. If the resource did not exist before the PUT request, the request creates
a new one with the given representation.
A common point of confusion is how resource names (URIs) apply to PUT versus POST
requests. A PUT request must always be directed toward the URI of the resource in
question; even if creating a new resource, the URI must be that of the resource to be
created. If the client does not know the URI of the resource (for example, if it is
derived from a server-generated ID), a POST request should be used.
Safe and Idempotent Methods
One purpose of the HTTPstandard is to define the implicit meanings of the various
HTTPmethods. This is the mental working model that many developers use when
working on web applications: GET retrieves a representation, PUT updates a resource,
and so on.
Pages:
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295