RESTfulness refers to resources - so a 'forbidden' message (say, due to a cookie being deleted) indicates a lack of success at accessing a resource, rather than indicating a different system state. Similarly, the access level of a user based on information set in a cookie might receive a different rendering of the same 'thing' (resource), but is still basically the same thing.
Resources are considered 'nouns'; the operation is a considered a verb. So using the HTTP GET method on a resource can be understood as 'Getting some information about this noun (thing)'. Similarly PUTting and POSTing are understood to have certain meanings and behaviour. It appears fairly clear from the URL what the desired resource is, as well as the nature of the operation (as defined by the HTTP method, GET, POST, PUT, etc).
One of the purposes of REST is to ensure that pages can be cached. The formal REST spec provides for caching servers to ensure that appropriate cached copies are returned (the header including cookies are examined). Idempotency is an important feature of RESTful systems - defined as something along the lines of if a function is applied to something, applying the same function again and again should not change the result. A nice example is the absolute value function in mathematics.
RESTful systems are often exemplified by referring to resources in a URL, so:
- www.domain.org/database might refer to a database
- www.domain.org/database/tables/1 might refer to table1 on database
- www.domain.org/database/tables/1/rows/5 might refer to the 5th row of the database table 1
And:
- If a GET request is directed to www.domain.org/database/tables/1, the system might return the contents of table1 in database.
- If a GET request is directed to www.domain.org/database/tables/1/rows/5, the system might return the contents of row5 of table1 in database.
- If a POST submission is made to www.domain.org/database/tables/1/rows, it will add a record containing information in the POST submission
- If a PUT submission is made to www.domain.org/database/tables/1/rows/5, the 5th row of the database table is updated.
Ultimately, this is a subjective issue of where to draw the line and what to consider a resource and various other things. Dan reckons it is increasingly a return to the original concepts of the web.
From: http://en.wikipedia.org/wiki/REST; http://www.xfront.com/, Billingsley W (pers. comm.) and Basman A (pers. comm.)
No comments:
Post a Comment