10. REST principles in
practice
• Everything is a Resource
• bookmarks
• orders
• employees
• media files
11. REST principles in
practice
• Resources have Names
• http://del.icio.us/pkeane/rest
• http://.../orders/234
• http://.../employee/pkeane
• http://.../funnycats.jpg
12. REST principles in
practice
• Simple operations
• GET http://del.icio.us/pkeane
• POST to http://.../orders
• PUT http://.../employee/pkeane
• DELETE http://.../funnycats.jpg
13. REST principles in
practice
• Resources have Representations
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Example Feed</title>
<link href="http://example.org/"/>
<updated>2003-12-13T18:30:02Z</updated>
<author>
<name>John Doe</name>
</author>
<id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id>
<entry>
[...]
</entry>
14. REST principles in
practice
• Resources have Representations
{
"updated": "2008-06-24T20:38:12-05:00",
"name": "search: Alfred Waud in american_west.artist",
"items": [ {
"media": {
"thumbnail": "http://dase/media/american_west/thumbnail/00194933_100.jpg",
"small": "http://dase/media/american_west/small/000194933_640.jpg”,
"medium": "http:/dase/media/american_west/medium/000194933_800.jpg",
"large": "http://dase/media/american_west/large/000194933_1024.jpg",
}}]
}
15. REST principles in
practice
• Resources have Representations
<html>
<head>
<title>funny cat picturs</title>
</head>
<body>
<h1>My Cat Ernie</h1>
<img src=”http://flickr.com/pkeane/set/33/image/2.jpg”/>
</body>
</html>
16. REST principles in
practice
• Resources have Representations
http://flickr.com/pkeane/set/33/image/2.jpg
17. REST principles in
practice
• Hypertext is the Engine of
Application State
18. REST principles in
practice
• Hypertext is the Engine of
Application State
Huh?
19. REST principles in
practice
• Hypertext is the Engine of
Application State
The representation ITSELF gives you all of
the information you need to perform
more useful operations.
20. REST principles in
practice
• Hypertext is the Engine of
Application State
• Links:
• <a href=”...”>news</a>
• <img src=”cat.png”/>
• <link type=”text/css” href=”style.css”/>
• Forms:
• <form action=”orders”
method=”post”>....</form>
22. RESTful Google Docs
GET LAITS
Google (Atom) Server
POST (form)
XHR (Atom)
Browser
23. Why REST?
• Developers have a better
understanding of the benefits of
HTTP & statelessness
• AJAX has made HTTP cool
• Django/Rails encourages good
RESTful practices (Struts didn’t)
24. Why REST?
• Mash-ups & Web 2.0
• Atom, JSON, XHTML
• Cloud Computing / Distributed
Systems