What does this definition of resource really mean?

5

I'm studying about web APIs and REST and the book I'm reading says the following:

  

The Web is built around three main concepts: features, URIs, and representations.

     

A resource is anything that has a URI. A feature itself is a conceptual mapping for one or more entities

That left me quite in doubt. I always found that a resource was the entity itself. For example, we have a index.html file that has a servidor.com/index.html URI, I thought the resource itself would be this file.

Another example of the same type would be a Cliente object that can be retrieved from a database through a URI containing its servidor.com/api/clientes/123 ID, again I thought the resource would be the returned object.

On the other hand, I know that a certain URI can simply receive data and perform some kind of action on the server, without returning or modifying a persisted entity on the server. The book even includes an example of this.

  A feature can be a service that provides an interface to anything like a catalog, a device (e.g., a printer), a wireless opener for a garage door ...

In both the printer and the garage door, there is no entity on the server. The URI will simply allow some code to be executed.

What does a feature mean to be a conceptual mapping for one or more entities?

Editing: Thinking a little about this I came up with the following way of thinking: a resource is anything that can be reached from a URL. For example, the homepage of a website, or a client with a certain ID. The resource is not the index.html file itself, nor the JSON object containing the client data, because these two things are just the state of it at that moment (they are representations), so the resource is actually the concept behind it of these states: both the page and the client.

Is this what a feature is? If yes, why can this be considered a conceptual mapping for one or more entities?

    
asked by anonymous 31.01.2015 / 03:11

1 answer

4

Terminological confusions like this are common, especially with such broad terms and in the context of the web, whose specifications always follow usage, not vice versa. At the beginning, resource was not even defined in any specification. There was a general notion that URLs (still "Universal" rather than "Uniform") pointed to some physical resource, such as a disk file.

Later, other uses appeared, and URIs were defined as "conceptual mapping" in 1998 RFC 2396 . It also says that the resource is "anything that has an identity" (whose identifier is the URI itself). It was a way of trying to say a URI does not have to correspond to something physical (like a person or a series of data) or even concrete; can even represent a concept.

These terms must have been confusing because in the 2005 version ( RFC 3986 ) they were removed and a definition which does not even try to define anything:

  

This specification does not limit the scope of what can be considered a resource; the term "resource" is used in the general sense for anything that can be identified by a URI.

That's it, it can be anything. If you look at RDF , for example, URIs represent anything even, including many concepts, such as authoring. And the URIs do not even have to be accessible via any network, in any protocol. In HTTP, for example, they can seamlessly lead to a 404. On you said, that "the resource is in reality the concept that lies behind these states," can be. It depends. The definition in the current standard is so broad that it does not restrict one to think so, while leaving room for uses that do not fit this interpretation. Always take this into consideration, there is no point in looking for the definitive answer on what can be a resource, since the term, within the context of what a URI can point to, is extremely broad.

Additional reference: Web resource in Wikipedia EN.

    
01.02.2015 / 03:34