Because the problem REST solves is that of managing a distributed network of documents, its unit of storage is the document, or in REST terms the resource. A static web page is a resource according to REST, but so is one that's dynamically generated by a web application. On the web, anything interesting you can get with your web browser is a resource.

Each resource has at least one unique identifier, a string that names it and no other resource. In the world of HTTP, this is the resource's URL. The resource identifier identifies a well-known resource that talks about Python. is another identifier for the same resource. is an identifier denoting a dynamic resource: one created upon request by a web application. This custom-made resource is an index full of references to other resources; all of which should pertain in some way to Python (the language or the snake). It didn't have to be this way: WAIS, one of the technologies subsumed by the web, treated searches and search results as first-class objects. In the REST architecture, these things only exist within resources and their identifiers.

A web object that can't be reached by typing an address is not technically a REST resource, because it has no identifier. If you can only get to a web page by submitting a form in your web browser, that page is not a resource; it's a side effect of your form submission. It's generally a good idea to make your web pages real resources. A resource is more useful than a nonresource that contains the same information: It can be bookmarked, passed around to others, accessed automatically, and used as input to scripts that manipulate resources.

Was this article helpful?

0 0

Post a comment