Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Grokking the
REST Architectural Style


Ben Ramsey ■ Dutch PHP Conference ■ 12 June 2009
Yes.
I am this guy.
Roatan Beach - Perfect Day, by Janusz Leszczynski




REST
Is it about
pretty URLs?




        Tom Coates, by Patrick Lauke
#webdevgangsign




How about XML
 over HTTP?         Web Developer Gang Sign, by Josh Lewis
Any web service that’s
not SOAP?




                         A Bar of Ivory Soap, by iirraa
Representational
State Transfer Restful Summer, by Clear Inner Vision
Public Domain, from Wikimedia Commons




Theory
of REST
REST defines a style by
which a resource’s state
may be transferred using a
representation of that
resource.
Client-server
Separated, by Hansol Lee
Stateless




      Stateless by Koesmanto Bong
Cache




Cache County, Utah by J. Stephen Conn
1.Identification of resources
2.Representation of resources
3.Linked resources
4.Resource metadata




                    ...
Layered




          Sedimentary Layers by Mark Thurman
jeremyʼs tie by Gitchel
                          Code-on-demand
RESTful Benefits

Improved response time & reduced
server load
Improves server scalability
Requires less client-side softwa...
A Real-World
Analogy
               Money!, by Tracy Olson
RESTful
        Practice




Public Domain, from Wikimedia Commons
“[REST] is intended to evoke an image of
how a well-designed Web application
behaves: a network of web pages (a
virtual st...
Hypertext
Transfer
Protocol
        URIs provide unique addresses
Constrained interface with methods and
                 ...
HTTP Interface

Methods      Cut & Paste
GET          Copy
PUT          Paste Over
POST         Paste After
DELETE       C...
Content Types

HTTP supports content types through the
Content-Type header
A single resource can be transferred in
various...
Lifecycle of a Resource
                     1

      POST /content HTTP/1.1
      Host: example.org
      Content-Type: a...
Lifecycle of a Resource
                     3

      GET /content/1234 HTTP/1.1
      Host: example.org



              ...
Lifecycle of a Resource
                     5

      PUT /content/1234 HTTP/1.1
      Host: example.org
      Content-Typ...
Lifecycle of a Resource
                     7

      DELETE /content/1234 HTTP/1.1
      Host: example.org



           ...
Resource-oriented
         Architecture
1. Represent itself to the client
2. Transition from one state to the next
3. Dest...
Resource-oriented
         Architecture
Resources are addressable
Resources have no state
Resources are connected
Resource...
Resource-oriented
         Architecture
Query string parameters appropriate in
some cases
Pragmatic use of URIs instead of...
Resource-oriented
        Architecture
Should expose many URIs
Session cookies are not RESTful
Combined resources are REST...
Atom
A resource-oriented protocol for
publishing documents that sits on top of
HTTP




                                 M...
Atom
Entry Document
application/atom+xml;type=entry
Feed (Collection) Document
application/atom+xml;type=feed
Category Doc...
Atom Resource Lifecycle
                     1

        GET /index.atom HTTP/1.1
        Host: example.org


             ...
Atom Resource Lifecycle
                     3

      GET /archives.atom HTTP/1.1
      Host: example.org



             ...
Atom Resource Lifecycle
                     5

     GET /categories.atom HTTP/1.1
     Host: example.org



             ...
Atom Resource Lifecycle
                      7

POST /archives.atom HTTP/1.1
Host: example.org
Content-Type: application/...
Atom Resource Lifecycle
                      9

      GET /archives/1234.atom HTTP/1.1
      Host: example.org



       ...
Atom Resource Lifecycle
                      11

PUT /archives/1234.atom HTTP/1.1
Host: example.org
Content-Type: applica...
Atom Resource Lifecycle
                    13

   DELETE /archives/1234.atom HTTP/1.1
   Host: example.org



           ...
Resource-oriented
Design
1. Determine your resources

         User              Content
   /users              /content
 ...
Resource-oriented
Design
2. Decide the methods for each
   resource

/users /users/{username} /content /content/{ID}
 GET ...
Resource-oriented
Design
3. Link your resources

Users own content
Each user owns multiple content items
Each content item...
Resource-oriented
Design
4. Determine your data schemas

         User            Content
   id                id
   usern...
Resource-oriented
Design
5. Choose your content type(s)




                                 Before we had CAD, we had Lea...
In conclusion...




                   Conclusion, by Mark Cummins
Questions?




benramsey.com
Grokking the REST Architectural Style
Copyright © Ben Ramsey. Some rights reserved.

This work is licensed under a Creativ...
Upcoming SlideShare
Loading in …5
×

Grokking the REST Architectural Style

10,563 views

Published on

REST has become the hip, new buzzword of Web 2.0. But what makes an application RESTful? Pretty URLs? XML over HTTP? Any service that's not SOAP? In all the hype, the definition of REST has become clouded and diluted.

Forget what you thought you knew about REST. In this talk, Ben Ramsey reintroduces REST, placing it under a microscope, uncovering each constraint that forms REST's crucial principles. Ramsey explains how REST is a style for network-based software applications, emphasizing scalability and efficiency through separation of concerns and taking advantage of the Web as a platform for rich Internet applications.

Published in: Technology
  • The usage of imagery in this display is really efficient. You have done a fantastic job here friend.
    Sharika
    http://winkhealth.com http://financewink.com
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Grokking the REST Architectural Style

  1. Grokking the REST Architectural Style Ben Ramsey ■ Dutch PHP Conference ■ 12 June 2009
  2. Yes. I am this guy.
  3. Roatan Beach - Perfect Day, by Janusz Leszczynski REST
  4. Is it about pretty URLs? Tom Coates, by Patrick Lauke
  5. #webdevgangsign How about XML over HTTP? Web Developer Gang Sign, by Josh Lewis
  6. Any web service that’s not SOAP? A Bar of Ivory Soap, by iirraa
  7. Representational State Transfer Restful Summer, by Clear Inner Vision
  8. Public Domain, from Wikimedia Commons Theory of REST
  9. REST defines a style by which a resource’s state may be transferred using a representation of that resource.
  10. Client-server Separated, by Hansol Lee
  11. Stateless Stateless by Koesmanto Bong
  12. Cache Cache County, Utah by J. Stephen Conn
  13. 1.Identification of resources 2.Representation of resources 3.Linked resources 4.Resource metadata Uniform Interface used to interface, by Tom Hensel
  14. Layered Sedimentary Layers by Mark Thurman
  15. jeremyʼs tie by Gitchel Code-on-demand
  16. RESTful Benefits Improved response time & reduced server load Improves server scalability Requires less client-side software Depends less on vendor software No need for resource discovery Better long-term compatibility & evolvability than RPC Sand Banks Sunset, by Clear Inner Vision
  17. A Real-World Analogy Money!, by Tracy Olson
  18. RESTful Practice Public Domain, from Wikimedia Commons
  19. “[REST] is intended to evoke an image of how a well-designed Web application behaves: a network of web pages (a virtual state-machine), where the user progresses through an application by selecting links (state transitions), resulting in the next page (representing the next state of the application) being transferred to the user and rendered for their use.” — Roy Fielding Drip Drops and the Spider Web, by Mike Bitzenhofer
  20. Hypertext Transfer Protocol URIs provide unique addresses Constrained interface with methods and content types Transactions are atomic Built-in support for layering Provides for cache control #110 Hypertext Transfer Protocol, by maako
  21. HTTP Interface Methods Cut & Paste GET Copy PUT Paste Over POST Paste After DELETE Cut #110 Hypertext Transfer Protocol, by maako
  22. Content Types HTTP supports content types through the Content-Type header A single resource can be transferred in various content types Content negotiation used to tell the server what type to return to the client REST community doesn’t care for content negotiation #110 Hypertext Transfer Protocol, by maako
  23. Lifecycle of a Resource 1 POST /content HTTP/1.1 Host: example.org Content-Type: application/xml 2 HTTP/1.x 201 Created Date: Thu, 13 November 2008 16:43:56 GMT Location: /content/1234 #110 Hypertext Transfer Protocol, by maako
  24. Lifecycle of a Resource 3 GET /content/1234 HTTP/1.1 Host: example.org 4 HTTP/1.x 200 OK Date: Thu, 13 November 2008 16:44:13 GMT Content-Type: application/xml #110 Hypertext Transfer Protocol, by maako
  25. Lifecycle of a Resource 5 PUT /content/1234 HTTP/1.1 Host: example.org Content-Type: application/xml 6 HTTP/1.x 200 OK Date: Thu, 13 November 2008 16:48:26 GMT Content-Type: application/xml #110 Hypertext Transfer Protocol, by maako
  26. Lifecycle of a Resource 7 DELETE /content/1234 HTTP/1.1 Host: example.org 8 HTTP/1.x 204 No Content Date: Thu, 13 November 2008 16:50:47 GMT #110 Hypertext Transfer Protocol, by maako
  27. Resource-oriented Architecture 1. Represent itself to the client 2. Transition from one state to the next 3. Destroy itself Additionally, the system knows how to create a resource. Where I Teach, by Todd Ehlers
  28. Resource-oriented Architecture Resources are addressable Resources have no state Resources are connected Resources share the same interface Where I Teach, by Todd Ehlers
  29. Resource-oriented Architecture Query string parameters appropriate in some cases Pragmatic use of URIs instead of using HTTP headers RPC-style APIs are avoided Representation should have links URI templates specify URI families Where I Teach, by Todd Ehlers
  30. Resource-oriented Architecture Should expose many URIs Session cookies are not RESTful Combined resources are RESTful only if represented as a URI URIs should facilitate “cut & paste” Where I Teach, by Todd Ehlers
  31. Atom A resource-oriented protocol for publishing documents that sits on top of HTTP Molecule display, by Christian Guthier
  32. Atom Entry Document application/atom+xml;type=entry Feed (Collection) Document application/atom+xml;type=feed Category Document application/atomcat+xml Service Document application/atomsvc+xml Molecule display, by Christian Guthier
  33. Atom Resource Lifecycle 1 GET /index.atom HTTP/1.1 Host: example.org 2 HTTP/1.x 200 OK Date: Thu, 13 November 2008 17:13:14 GMT Content-Type: application/atomsvc+xml Molecule display, by Christian Guthier
  34. Atom Resource Lifecycle 3 GET /archives.atom HTTP/1.1 Host: example.org 4 HTTP/1.x 200 OK Date: Thu, 13 November 2008 17:13:46 GMT Content-Type: application/atom+xml;type=feed Molecule display, by Christian Guthier
  35. Atom Resource Lifecycle 5 GET /categories.atom HTTP/1.1 Host: example.org 6 HTTP/1.x 200 OK Date: Thu, 13 November 2008 17:13:48 GMT Content-Type: application/atomcat+xml Molecule display, by Christian Guthier
  36. Atom Resource Lifecycle 7 POST /archives.atom HTTP/1.1 Host: example.org Content-Type: application/atom+xml;type=entry 8 HTTP/1.x 201 Created Date: Thu, 13 November 2008 17:16:32 GMT Location: /archives/1234.atom Molecule display, by Christian Guthier
  37. Atom Resource Lifecycle 9 GET /archives/1234.atom HTTP/1.1 Host: example.org 10 HTTP/1.x 200 OK Date: Thu, 13 November 2008 17:16:36 GMT Content-Type: application/atom+xml;type=entry Molecule display, by Christian Guthier
  38. Atom Resource Lifecycle 11 PUT /archives/1234.atom HTTP/1.1 Host: example.org Content-Type: application/atom+xml;type=entry 12 HTTP/1.x 200 OK Date: Thu, 13 November 2008 17:23:12 GMT Content-Type: application/atom+xml;type=entry Molecule display, by Christian Guthier
  39. Atom Resource Lifecycle 13 DELETE /archives/1234.atom HTTP/1.1 Host: example.org 14 HTTP/1.x 204 No Content Date: Thu, 13 November 2008 19:34:29 GMT Molecule display, by Christian Guthier
  40. Resource-oriented Design 1. Determine your resources User Content /users /content /users/{username} /content/{ID} Before we had CAD, we had Lead!, by Wendell
  41. Resource-oriented Design 2. Decide the methods for each resource /users /users/{username} /content /content/{ID} GET GET GET GET POST PUT POST PUT DELETE DELETE Before we had CAD, we had Lead!, by Wendell
  42. Resource-oriented Design 3. Link your resources Users own content Each user owns multiple content items Each content item has one owner Before we had CAD, we had Lead!, by Wendell
  43. Resource-oriented Design 4. Determine your data schemas User Content id id username owner firstname title lastname file/content Before we had CAD, we had Lead!, by Wendell
  44. Resource-oriented Design 5. Choose your content type(s) Before we had CAD, we had Lead!, by Wendell
  45. In conclusion... Conclusion, by Mark Cummins
  46. Questions? benramsey.com
  47. Grokking the REST Architectural Style Copyright © Ben Ramsey. Some rights reserved. This work is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 United States License. For uses not covered under this license, please contact the author.

×