Verbs
Verbs correspond to actions on resources. A verb will either send a representation of
a resource from the server to the client or update the resource on the server with
information from the client.
In REST, verbs are a constrained territory. While the set of content types is open for
revision and expansion, and resource names are infinitely expandable, the set of
verbs is fixed. However, the constraints put on the scope of verbs allows them to be
universal; any verb can be applied to any noun.
188 | Chapter 7: REST, Resources, and Web Services
HTTPdefines a handful of methods; the set can be expanded by protocols such as
WebDAV, but the basic set is sufficient for REST. The four most common methods
are GET, PUT, DELETE, and POST; we will examine each of them and their purpose here.
We can form some linguistic analogies as a simplification of the four common verbs.
Roughly speaking, this is what they mean, using ???this??? to refer to the request body,
and ???there??? to refer to the URI acted upon:
??? GET: ???Give me whatever is there.???
??? PUT: ???Store this there.???
??? DELETE: ???Delete whatever is there.???
??? POST: ???Hey you there, process this.???
GET
The GET method transfers a representation of a resource from the server to the client.
It is used for read-only access to a resource. GET is by far the most common verb on
the Web; it is often the only method used on static web sites.
Pages:
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293