5. http://app.com/pics/1
What remains:
a (unique) resource identifier
an “abstract thing” that lives in the cloud
a.k.a. ”the intended conceptual target of a
hypertext reference” :]
a representation of the resource
(you can never access the resource itself, only various representations of it)
6. http:// GET app.com/pics/1
We have nouns (resources),
but what happened to the verbs?
http:// DELETE app.com/pics/1
they moved from the URL to the HTTP request method !
9. REST is about resources
Nouns
URIs
(unconstrained)
Verbs
GET, PUT, POST, DELETE
(constrained)
Content Types
HTML, JPEG, XML etc.
(constrained)
10. GET /pics/1
Accept: JPEG
or GET /pics/1.jpg
Requesting different
resource representations
GET /pics/1
Accept: XML
or GET /pics/1.xml
<picture>
<place>Axe Lake</place>
<size>1024x768</size>
<date>2008-05-01</date>
</picture>
11. GET /people
Accept: XML
Plural resources
GET /people/1
Accept: JPEG
<people>
<person>
<id>1</id>
<name>Ann</name>
<age>28</age>
</person>
<person>
<id>2</id>
<name>Bruce</name>
<age>32</age>
</person>
...
</people>
12. It relies on the following standards though:
HTTP
URL
XML/HTML/GIF/JPEG/etc
(resource representations)
text/xml, text/html, image/gif, image/jpeg, etc.
(content types)
remember
REST is not a standard!
20. Nested resources (in Rails 2)
http://adam.blog.heroku.com/past/2007/12/20/nested_resources_in_rails_2/
/events/1/tickets
21. A resource is not always a one-to-one
mapping to a Rails model or database table.
Sometimes a resource is "virtual" and exists in
your domain vocabulary and application logic,
but is not backed by a database table. [2]
GOOD TO KNOW
models != resources
22. To create a website that is:
• easy to use
• easy to maintain
• easy to cache
• easy to scale
Why use REST?
23. Thank you!
Resources (n.p.i.)
[1] Roy Fielding’s dissertation (2000)
www.ics.uci.edu/~fielding/pubs/dissertation/top.htm
[2] REST 101
www.softiesonrails.com/search?q=rest+101
[3] A Brief Introduction to REST
www.infoq.com/articles/rest-introduction
[4] How I Explained REST to My Wife
tomayko.com/writings/rest-to-my-wife