Grokking the REST Architectural Style
Upcoming SlideShare
Loading in...5
×
 

Grokking the REST Architectural Style

on

  • 10,169 views

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 ...

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.

Statistics

Views

Total Views
10,169
Views on SlideShare
9,334
Embed Views
835

Actions

Likes
21
Downloads
287
Comments
1

16 Embeds 835

http://techportal.ibuildings.com 477
http://kmoonki.tistory.com 221
http://techportal.inviqa.com 64
http://wiki.bcmoney-mobiletv.com 34
http://www.slideshare.net 24
http://blog.ibuildings.com 3
http://feeds2.feedburner.com 2
http://static.slidesharecdn.com 2
http://www.php-talks.com 1
http://techportal.development.local 1
http://translate.googleusercontent.com 1
https://si0.twimg.com 1
http://us-w1.rockmelt.com 1
http://ignar.name 1
http://feeds.feedburner.com 1
http://webcache.googleusercontent.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

CC Attribution-NonCommercial-NoDerivs LicenseCC Attribution-NonCommercial-NoDerivs LicenseCC Attribution-NonCommercial-NoDerivs License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • 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
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • <br />
  • <br />
  • <br />
  • <br />
  • Is REST about so-called “pretty” URLs? <br /> <br /> Tom Coates, who apparently made this statement at a “Future of Web Apps” summit. <br />
  • If you want to be real cool, take a pic of yourself doing this and post it to Flickr with the tag “webdevgangsign.” <br />
  • Or not RPC (remote procedure call)? <br />
  • * Representational State Transfer <br /> <br /> * Term originated in 2000 in Roy Fielding’s doctoral dissertation about the Web entitled “Architectural Styles and the Design of Network-based Software Architectures” <br /> <br /> * Not an architecture or a standard for developing web services <br /> <br /> * Not a particular format or pattern <br /> <br /> * It is a set of design principles <br />
  • <br />
  • There are six major constraints that define the REST architectural style. <br />
  • There are six major constraints that define the REST architectural style. <br />
  • There are six major constraints that define the REST architectural style. <br />
  • There are six major constraints that define the REST architectural style. <br />
  • The client-server relationship provides for a separation of concerns. This separation is very important to REST. IMO, it’s perhaps the most important constraint. We’re all-too-familiar with the client-server relationship, since it’s how the Web works, but it’s also what makes the other REST constraints possible and beneficial. <br />
  • <br />
  • <br />
  • What is a resource? <br /> <br /> From RFC 2396: “A resource can be anything that has identity. Familiar examples include an electronic document, an image, a service (e.g., ‘today’s weather report for Los Angeles’), and a collection of other resources. Not all resources are network ‘retrievable’; e.g., human beings, corporations, and bound books in a library can also be considered resources.” <br /> <br /> All resources share a uniform interface for the transfer of state between client and resource, consisting of <br /> <br /> - A constrained set of well-defined operations <br /> - A constrained set of content types, optionally supporting code on demand <br /> <br />
  • What is a resource? <br /> <br /> From RFC 2396: “A resource can be anything that has identity. Familiar examples include an electronic document, an image, a service (e.g., ‘today’s weather report for Los Angeles’), and a collection of other resources. Not all resources are network ‘retrievable’; e.g., human beings, corporations, and bound books in a library can also be considered resources.” <br /> <br /> All resources share a uniform interface for the transfer of state between client and resource, consisting of <br /> <br /> - A constrained set of well-defined operations <br /> - A constrained set of content types, optionally supporting code on demand <br /> <br />
  • What is a resource? <br /> <br /> From RFC 2396: “A resource can be anything that has identity. Familiar examples include an electronic document, an image, a service (e.g., ‘today’s weather report for Los Angeles’), and a collection of other resources. Not all resources are network ‘retrievable’; e.g., human beings, corporations, and bound books in a library can also be considered resources.” <br /> <br /> All resources share a uniform interface for the transfer of state between client and resource, consisting of <br /> <br /> - A constrained set of well-defined operations <br /> - A constrained set of content types, optionally supporting code on demand <br /> <br />
  • What is a resource? <br /> <br /> From RFC 2396: “A resource can be anything that has identity. Familiar examples include an electronic document, an image, a service (e.g., ‘today’s weather report for Los Angeles’), and a collection of other resources. Not all resources are network ‘retrievable’; e.g., human beings, corporations, and bound books in a library can also be considered resources.” <br /> <br /> All resources share a uniform interface for the transfer of state between client and resource, consisting of <br /> <br /> - A constrained set of well-defined operations <br /> - A constrained set of content types, optionally supporting code on demand <br /> <br />
  • <br />
  • <br />
  • Advocates claim that REST: <br /> <br /> * Provides improved response time and reduced server load due to its support for the caching of representations <br /> * Improves server scalability by reducing the need to maintain session state. This means that different servers can be used to handle different requests in a session <br /> * Requires less client-side software to be written than other approaches, because a single browser can access any application and any resource <br /> * Depends less on vendor software and mechanisms which layer additional messaging frameworks on top of HTTP <br /> * Provides equivalent functionality when compared to alternative approaches to communication <br /> * Does not require a separate resource discovery mechanism, due to the use of hyperlinks in representations <br /> * Provides better long-term compatibility and evolvability characteristics than RPC. This is due to: <br /> - The capability of document types such as HTML to evolve without breaking backwards- or forwards-compatibility <br /> - The ability of resources to add support for new content types as they are defined without dropping or reducing support for older content types. <br /> <br /> One benefit that's obvious with regards to web based applications is that a ReSTful implementation allows a user to bookmark specific \"queries\" (or requests) and allows those to be conveyed to others across e-mail, instant messages, or to be injected into wikis, etc. Thus this \"representation\" of a path or entry point into an application state becomes highly portable <br /> <br />
  • Advocates claim that REST: <br /> <br /> * Provides improved response time and reduced server load due to its support for the caching of representations <br /> * Improves server scalability by reducing the need to maintain session state. This means that different servers can be used to handle different requests in a session <br /> * Requires less client-side software to be written than other approaches, because a single browser can access any application and any resource <br /> * Depends less on vendor software and mechanisms which layer additional messaging frameworks on top of HTTP <br /> * Provides equivalent functionality when compared to alternative approaches to communication <br /> * Does not require a separate resource discovery mechanism, due to the use of hyperlinks in representations <br /> * Provides better long-term compatibility and evolvability characteristics than RPC. This is due to: <br /> - The capability of document types such as HTML to evolve without breaking backwards- or forwards-compatibility <br /> - The ability of resources to add support for new content types as they are defined without dropping or reducing support for older content types. <br /> <br /> One benefit that's obvious with regards to web based applications is that a ReSTful implementation allows a user to bookmark specific \"queries\" (or requests) and allows those to be conveyed to others across e-mail, instant messages, or to be injected into wikis, etc. Thus this \"representation\" of a path or entry point into an application state becomes highly portable <br /> <br />
  • Advocates claim that REST: <br /> <br /> * Provides improved response time and reduced server load due to its support for the caching of representations <br /> * Improves server scalability by reducing the need to maintain session state. This means that different servers can be used to handle different requests in a session <br /> * Requires less client-side software to be written than other approaches, because a single browser can access any application and any resource <br /> * Depends less on vendor software and mechanisms which layer additional messaging frameworks on top of HTTP <br /> * Provides equivalent functionality when compared to alternative approaches to communication <br /> * Does not require a separate resource discovery mechanism, due to the use of hyperlinks in representations <br /> * Provides better long-term compatibility and evolvability characteristics than RPC. This is due to: <br /> - The capability of document types such as HTML to evolve without breaking backwards- or forwards-compatibility <br /> - The ability of resources to add support for new content types as they are defined without dropping or reducing support for older content types. <br /> <br /> One benefit that's obvious with regards to web based applications is that a ReSTful implementation allows a user to bookmark specific \"queries\" (or requests) and allows those to be conveyed to others across e-mail, instant messages, or to be injected into wikis, etc. Thus this \"representation\" of a path or entry point into an application state becomes highly portable <br /> <br />
  • Advocates claim that REST: <br /> <br /> * Provides improved response time and reduced server load due to its support for the caching of representations <br /> * Improves server scalability by reducing the need to maintain session state. This means that different servers can be used to handle different requests in a session <br /> * Requires less client-side software to be written than other approaches, because a single browser can access any application and any resource <br /> * Depends less on vendor software and mechanisms which layer additional messaging frameworks on top of HTTP <br /> * Provides equivalent functionality when compared to alternative approaches to communication <br /> * Does not require a separate resource discovery mechanism, due to the use of hyperlinks in representations <br /> * Provides better long-term compatibility and evolvability characteristics than RPC. This is due to: <br /> - The capability of document types such as HTML to evolve without breaking backwards- or forwards-compatibility <br /> - The ability of resources to add support for new content types as they are defined without dropping or reducing support for older content types. <br /> <br /> One benefit that's obvious with regards to web based applications is that a ReSTful implementation allows a user to bookmark specific \"queries\" (or requests) and allows those to be conveyed to others across e-mail, instant messages, or to be injected into wikis, etc. Thus this \"representation\" of a path or entry point into an application state becomes highly portable <br /> <br />
  • Advocates claim that REST: <br /> <br /> * Provides improved response time and reduced server load due to its support for the caching of representations <br /> * Improves server scalability by reducing the need to maintain session state. This means that different servers can be used to handle different requests in a session <br /> * Requires less client-side software to be written than other approaches, because a single browser can access any application and any resource <br /> * Depends less on vendor software and mechanisms which layer additional messaging frameworks on top of HTTP <br /> * Provides equivalent functionality when compared to alternative approaches to communication <br /> * Does not require a separate resource discovery mechanism, due to the use of hyperlinks in representations <br /> * Provides better long-term compatibility and evolvability characteristics than RPC. This is due to: <br /> - The capability of document types such as HTML to evolve without breaking backwards- or forwards-compatibility <br /> - The ability of resources to add support for new content types as they are defined without dropping or reducing support for older content types. <br /> <br /> One benefit that's obvious with regards to web based applications is that a ReSTful implementation allows a user to bookmark specific \"queries\" (or requests) and allows those to be conveyed to others across e-mail, instant messages, or to be injected into wikis, etc. Thus this \"representation\" of a path or entry point into an application state becomes highly portable <br /> <br />
  • Advocates claim that REST: <br /> <br /> * Provides improved response time and reduced server load due to its support for the caching of representations <br /> * Improves server scalability by reducing the need to maintain session state. This means that different servers can be used to handle different requests in a session <br /> * Requires less client-side software to be written than other approaches, because a single browser can access any application and any resource <br /> * Depends less on vendor software and mechanisms which layer additional messaging frameworks on top of HTTP <br /> * Provides equivalent functionality when compared to alternative approaches to communication <br /> * Does not require a separate resource discovery mechanism, due to the use of hyperlinks in representations <br /> * Provides better long-term compatibility and evolvability characteristics than RPC. This is due to: <br /> - The capability of document types such as HTML to evolve without breaking backwards- or forwards-compatibility <br /> - The ability of resources to add support for new content types as they are defined without dropping or reducing support for older content types. <br /> <br /> One benefit that's obvious with regards to web based applications is that a ReSTful implementation allows a user to bookmark specific \"queries\" (or requests) and allows those to be conveyed to others across e-mail, instant messages, or to be injected into wikis, etc. Thus this \"representation\" of a path or entry point into an application state becomes highly portable <br /> <br />
  • Humans live in the world of representations. Representation, as a concept, is an attempt (arguably futile) to reach certain acceptable level of objectivity. <br /> <br /> For example, if a person wants to buy a house, that person needs to qualify for a mortgage. If that person explains to the mortgage broker that he has $50,000.00 cash available for the down payment toward purchasing the house, the broker will not go ahead and approve the mortgage, even though the quoted amount would be fully satisfactory. What the mortgage broker needs is a more objective argument that would reassure the issuer that the party asking for the mortgage does indeed have enough money for the down payment. <br /> <br /> But how is the issuer to go about obtaining the more objective proof? Certainly not by going directly into the applicant's safety vault and counting the money deposited there. Instead, the issuer is simply expecting to receive a representation of that person's balance in his bank account. <br /> <br /> That representation projects a sufficient illusion of objectivity, so that the involved parties could sufficiently relax and that the business transaction can eventually take place. <br /> <br /> In the same manner, any transaction that transpires on the web is based on the similar representational logic. The actual resource is never being touched. Instead, various representations of the said resource are being prepared, rendered, and shipped to the clients for consumption. Same as in the real world, where the mortgage issuer will never actually touch client's money, but will instead be satisfied with a mere piece of paper representing the balance, resources on the web never get to be directly manipulated by the clients. <br />
  • <br />
  • <br />
  • <br />
  • URIs uniquely address resources <br /> <br /> HTTP methods (GET, POST, PUT, DELETE) and content types (text/html, text/plain, etc.) provide a constrained interface <br /> <br /> All transactions are atomic <br /> <br /> HTTP provides cache control <br /> <br /> HTTP provides layering <br />
  • URIs uniquely address resources <br /> <br /> HTTP methods (GET, POST, PUT, DELETE) and content types (text/html, text/plain, etc.) provide a constrained interface <br /> <br /> All transactions are atomic <br /> <br /> HTTP provides cache control <br /> <br /> HTTP provides layering <br />
  • URIs uniquely address resources <br /> <br /> HTTP methods (GET, POST, PUT, DELETE) and content types (text/html, text/plain, etc.) provide a constrained interface <br /> <br /> All transactions are atomic <br /> <br /> HTTP provides cache control <br /> <br /> HTTP provides layering <br />
  • URIs uniquely address resources <br /> <br /> HTTP methods (GET, POST, PUT, DELETE) and content types (text/html, text/plain, etc.) provide a constrained interface <br /> <br /> All transactions are atomic <br /> <br /> HTTP provides cache control <br /> <br /> HTTP provides layering <br />
  • URIs uniquely address resources <br /> <br /> HTTP methods (GET, POST, PUT, DELETE) and content types (text/html, text/plain, etc.) provide a constrained interface <br /> <br /> All transactions are atomic <br /> <br /> HTTP provides cache control <br /> <br /> HTTP provides layering <br />
  • URIs uniquely address resources <br /> <br /> HTTP methods (GET, POST, PUT, DELETE) and content types (text/html, text/plain, etc.) provide a constrained interface <br /> <br /> All transactions are atomic <br /> <br /> HTTP provides cache control <br /> <br /> HTTP provides layering <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />

Grokking the REST Architectural Style Grokking the REST Architectural Style Presentation Transcript

  • 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 Uniform Interface used to interface, by Tom Hensel
  • 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 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
  • 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 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
  • 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
  • HTTP Interface Methods Cut & Paste GET Copy PUT Paste Over POST Paste After DELETE Cut #110 Hypertext Transfer Protocol, by maako
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • Resource-oriented Architecture Resources are addressable Resources have no state Resources are connected Resources share the same interface Where I Teach, by Todd Ehlers
  • 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
  • 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
  • Atom A resource-oriented protocol for publishing documents that sits on top of HTTP Molecule display, by Christian Guthier
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • Resource-oriented Design 1. Determine your resources User Content /users /content /users/{username} /content/{ID} Before we had CAD, we had Lead!, by Wendell
  • 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
  • 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
  • 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
  • Resource-oriented Design 5. Choose your content type(s) Before we had CAD, we had Lead!, by Wendell
  • 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 Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 United States License. For uses not covered under this license, please contact the author.