An HTTP Resource is a lot simpler than you might think

Tags: HTTP, REST

Unfortunately, I still regularly run into articles on the web that misunderstand the concept of an HTTP resource.  Considering it is a core piece of web architecture, having a clear understanding of what it means can make many other pieces of web architectural guidance considerably easier to understand.

To try and keep this post as practical as possible, let’s first consider some URLs.

http://customers example.org/10 
http://example.org/customers?id=10 
http://example.org/customers 
http://example.org/customers?active=true 
http://example.org/customers/10/edit

How many resources are being identified by these five URLs? 

DogTags

If all of those requests return some kind of 2XX response, then there are five distinct information resources.  The presence of query strings parameters, or path parameters, or verbs or nouns, or plurals or singular terms, has no bearing on the fact that that these are distinct web identifiers that identify distinct resources. 

Time to set the record straight

Let me give a few examples that seem to confuse people:

Resources > Entities

Another common misconception is that resources are limited to exposing entities from your application domain.  Here are some examples of resources that are perfectly valid despite what you might read on the internet:

http://example.org/dashboard
http://example.org/printer 
http://example.org/barcodeprocessor
http://example.org/invoice/32/status 
http://example.org/searchform
http://example.org/calculator

It’s very simple

A resource is some piece of information that is exposed on the web using an URL as an identifier.  Try not to read anything more into the definition than that. 

No Comments

Add a Comment

comments powered by Disqus