real world rest with atom/atompub

29
Real World REST with Atom/AtomPub

Upload: peter-keane

Post on 20-Jun-2015

3.024 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Real World REST with Atom/AtomPub

Real World RESTwith Atom/AtomPub

Page 2: Real World REST with Atom/AtomPub

What is REST?

•set of design principles

•widely implemented (the Web!)

• a term coined by Roy Fielding for his doctoral dissertation

Page 3: Real World REST with Atom/AtomPub

What is REST?

•a useful set of best practices for building web apps

• an “interface” for the web

• simple (but not necessarily easy)

Page 4: Real World REST with Atom/AtomPub

RESTful Apps

•“play well” with others

• are evolvable

• are robust & maintainable

• can be secure

Page 5: Real World REST with Atom/AtomPub

What is Atom?

•a simple XML format

• very similar to RSS

• useful for representing web content

Page 6: Real World REST with Atom/AtomPub

What is AtomPub?

•Atom Publishing Protocol

• a standard for “writing” to the web

• based on REST principles

Page 7: Real World REST with Atom/AtomPub

Who is implementing Atom/AtomPub?

•Google

•Microsoft

• IBM

•LAITS :-)

Page 8: Real World REST with Atom/AtomPub

REST principles

•Everything is a Resource

•Resources have Names

•Simple operations (GET, PUT, POST,

DELETE)

Page 9: Real World REST with Atom/AtomPub

REST principles

•Resources have Representations

•Hypermedia is the Engine of Application State

Page 10: Real World REST with Atom/AtomPub

REST principles in practice

• Everything is a Resource

• bookmarks

• orders

• employees

• media files

Page 11: Real World REST with Atom/AtomPub

REST principles in practice

• Resources have Names

• http://del.icio.us/pkeane/rest

• http://.../orders/234

• http://.../employee/pkeane

• http://.../funnycats.jpg

Page 12: Real World REST with Atom/AtomPub

REST principles in practice

• Simple operations

• GET http://del.icio.us/pkeane

• POST to http://.../orders

• PUT http://.../employee/pkeane

• DELETE http://.../funnycats.jpg

Page 13: Real World REST with Atom/AtomPub

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>

Page 14: Real World REST with Atom/AtomPub

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", } } ]}

Page 15: Real World REST with Atom/AtomPub

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>

Page 16: Real World REST with Atom/AtomPub

REST principles in practice

• Resources have Representationshttp://flickr.com/pkeane/set/33/image/2.jpg

Page 17: Real World REST with Atom/AtomPub

REST principles in practice

• Hypertext is the Engine of Application State

Page 18: Real World REST with Atom/AtomPub

REST principles in practice

• Hypertext is the Engine of Application State

Huh?

Page 19: Real World REST with Atom/AtomPub

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.

Page 20: Real World REST with Atom/AtomPub

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>

Page 21: Real World REST with Atom/AtomPub

REST in DASe

Page 22: Real World REST with Atom/AtomPub

RESTful Google Docs

Google LAITS Server

Browser

POST (form)XHR (Atom)

GET (Atom)

Page 23: Real World REST with Atom/AtomPub

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)

Page 24: Real World REST with Atom/AtomPub

Why REST?

•Mash-ups & Web 2.0

•Atom, JSON, XHTML

•Cloud Computing / Distributed Systems

Page 25: Real World REST with Atom/AtomPub

Topics/Ideas

• loose coupling

• “engineer for serendipity”

• resources, not procedures

• reuse

Page 26: Real World REST with Atom/AtomPub

Topics/Ideas

• functional programming at web-scale

• declarative syntaxes

• high value on good specs

•mime-types

Page 27: Real World REST with Atom/AtomPub

Topics/Ideas

•decomposition

• complex procedures can be modeled as document passing

• simple/generic interfaces

•UNIX philosophy

Page 28: Real World REST with Atom/AtomPub

Resources

•http://del.icio.us/pkeane/rest+fyi

• http://dase.googlecode.com