What does this definition of resource really mean?

Asked

Viewed 238 times

5

I’m studying about web API’s and REST and the book I’m reading says the following:

The Web is built around three main concepts: resources, URI’s, and representations.

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

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

Another example of the same type would be to have an object Cliente which can be retrieved from a database via a URI containing your ID servidor.com/api/clientes/123, again I thought the feature 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 persistent entity on the server. The book even gives 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 the case of both the printer and the garage door, there is in fact no entity on the server. The URI will simply allow the execution of some code.

What it means to be a conceptual mapping to one or more entities?

Editing: Thinking a little about this I arrived at the following way of thinking: a resource is anything that can be accessed from a URL. For example, the homepage of a website, or a client with a certain ID. The feature is not the file index.html in itself, neither the JSON object containing the client data, because these two things are only the state of it at that time (are representations), so the feature is in reality the concept that lies behind these states: both the page, and the client.

Is that what a resource is? If so, why can it be considered a conceptual mapping to one or more entities?

  • It has a URL and it has a URI. The concepts are a little different. Here’s an English page that puts a little light on it. http://searchsoa.techtarget.com/definition/URI

  • Thanks @Peter, I know, URI’s can be both URL’s and URN’s. With regards to URI’s and representations I think I get the idea. What I’m not understanding very well is why a resource is a mapping to one or more entities.

  • "In the case of both the printer and the garage door, there is in fact no interface on the server.". I think so. Try to format the hard drive fully, then turn on the printer. Nothing will come out on paper. It has a "software" interface (driver) and also has a physical interface to communicate. Same thing with the keyboard (formerly type ACIA 6850 for example). So we can probably say that ACIA 6850 is a physical "resource" type "input". Not very easy, but interesting! :)

1 answer

4


Terminological confusions like this are common, especially with such broad terms and in the context of the web, whose specifications always succeed the use itself, and not the other way around. At first, Resource was not even defined in any specification. There was a general notion that Urls (still "Universal" and not "Uniform") pointed to some physical resource, such as a disk file.

Later, other uses appeared, and Uris were defined as "conceptual mapping" in the RFC 2396 1998. She 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 need to correspond to something physical (like a person or a set of data) or even concrete; it may even represent a concept.

These terms must have been confusing, because in the 2005 version (RFC 3986) have been removed and inserted a setting that no longer tries to define anything:

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

That’s it, it could be anything. If you look at the RDF, for example, Uris represent anything at all, including many concepts, such as authorship. And Uris do not even need to be accessible via any network, in any protocol. In HTTP, for example, they can easily lead to a 404. About you said, that "the resource is actually the concept that lies behind these states," it can be. It depends. The definition in the current standard is so broad that it does not restrict thinking like that, while leaving room for uses that do not fit this interpretation. Always take this into account, it is no use to keep looking for the definitive answer about what a resource can be, because the term, within the context of what a URI can point to, is extremely broad.


Additional reference: Web Resource in Wikipedia EN.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.