0
HTTP, REST  and the PATCH verb (accompanied by kittens) Thomas Parslow @almostobsolete http://almostobsolete.net
Web services <ul><li>The web is used by machines as well as humans </li></ul><ul><li>Web services are like web sites for m...
HTTP is awesome! <ul><li>Simple </li></ul><ul><li>Common set of operations </li></ul><ul><li>Libraries in every language <...
REST <ul><li>Think in nouns not verbs! </li></ul><ul><li>Resources are nouns </li></ul><ul><li>Resources are addressable a...
Current main HTTP verbs GET PUT DELETE POST Show! Replace! Destroy! Do stuff!
Why REST? Trendy buzzword Discoverable, self describing APIs Less special cases and one offs More maintanable Less code!
Real world example:  Telephone conference control Conference Caller Get conference details ( GET ) Lock/Unlock Record On/ ...
Conference {    &quot;type&quot;: &quot;conference&quot;,    &quot;href&quot;: &quot;http://example.com/conferences/1&quot...
Real world example:  Telephone conference control Conference Caller Get conference details ( GET ) Lock/Unlock ( PUT ) Rec...
Partial updates <ul><li>   WHY? </li></ul><ul><li>Efficiency: Large resources </li></ul><ul><li>Concurrency: Multiple peop...
The PATCH Verb <ul><li>New HTTP verb </li></ul><ul><li>Partially updates a document </li></ul><ul><li>Neither idempotent n...
JSONPatch    <ul><li>A patch format for JSON documents </li></ul><ul><li>http://tools.ietf.org/html/draft-pbryan-json-patc...
Thanks for listening! Questions? @almostobsolete
Upcoming SlideShare
Loading in...5
×

REST, HTTP, and the PATCH verb (with kittens)

547

Published on

RESTful web services and the new HTTP PATCH Verb (with the JSONPatch patch format). Plus kittens.

My BarCamp London 9 talk!

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
547
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "REST, HTTP, and the PATCH verb (with kittens)"

  1. 1. HTTP, REST  and the PATCH verb (accompanied by kittens) Thomas Parslow @almostobsolete http://almostobsolete.net
  2. 2. Web services <ul><li>The web is used by machines as well as humans </li></ul><ul><li>Web services are like web sites for machines </li></ul><ul><li>Various ways to design web services </li></ul><ul><li>RPC </li></ul><ul><li>SOAP (please no) </li></ul>
  3. 3. HTTP is awesome! <ul><li>Simple </li></ul><ul><li>Common set of operations </li></ul><ul><li>Libraries in every language </li></ul><ul><li>Compression? </li></ul><ul><li>Encryption? </li></ul><ul><li>Cacheing? </li></ul><ul><li>Http has got it covered... </li></ul>
  4. 4. REST <ul><li>Think in nouns not verbs! </li></ul><ul><li>Resources are nouns </li></ul><ul><li>Resources are addressable and linked </li></ul><ul><li>http://example.com/blogpost/1 </li></ul><ul><li>NOT: http://example.com/get_blogpost </li></ul>
  5. 5. Current main HTTP verbs GET PUT DELETE POST Show! Replace! Destroy! Do stuff!
  6. 6. Why REST? Trendy buzzword Discoverable, self describing APIs Less special cases and one offs More maintanable Less code!
  7. 7. Real world example:  Telephone conference control Conference Caller Get conference details ( GET ) Lock/Unlock Record On/ Record Off End conference Add caller (dialout) Get List Of Callers Evict caller Mute Caller Unmute caller
  8. 8. Conference {   &quot;type&quot;: &quot;conference&quot;,   &quot;href&quot;: &quot;http://example.com/conferences/1&quot;,   &quot;head&quot;: {     &quot;allow&quot;: [ &quot;GET&quot;, &quot;DELETE&quot;, &quot;PUT&quot;, &quot;PATCH&quot; ],     &quot;created_at&quot;: &quot;2011-10-21T10:56:54Z&quot;,      &quot;related&quot;: {       &quot;callers&quot;: {&quot;href&quot;: &quot;http://example.com/conferences/1/callers&quot;}   },   &quot;body&quot;: {     &quot;recording&quot;: false,     &quot;locked&quot;: false   } } Caller List {   &quot;type&quot;: &quot;caller-list&quot;,   &quot;href&quot;: &quot;http://example.com/api/v1/conferences/1/callers&quot;,   &quot;head&quot;: {     &quot;allow&quot;: [&quot;GET&quot;, &quot;POST&quot;]   },   &quot;body&quot;: [     {&quot;href&quot;: &quot;http://example.com/conferences/1/callers/1&quot;}   ] } Caller {   &quot;type&quot;: &quot;caller&quot;,   &quot;href&quot;: &quot;http://example.com/conferences/1/callers/1&quot;,   &quot;head&quot;: {     &quot;allow&quot;: [ &quot;GET&quot;, &quot;DELETE&quot;, &quot;PUT&quot;, &quot;PATCH&quot; ]   },   &quot;body&quot;: {     &quot;phone_number&quot;: &quot;07951261227&quot;,     &quot;name&quot;: &quot;Tom&quot;,     &quot;type&quot;: &quot;chair&quot;,     &quot;muted&quot;: false   } } Real world example:  Telephone conference control Conference Caller
  9. 9. Real world example:  Telephone conference control Conference Caller Get conference details ( GET ) Lock/Unlock ( PUT ) Record On/ Record Off ( PUT ) End conference ( DELETE ) Get caller details ( GET ) Evict caller ( DELETE ) Mute Caller ( PUT ) Unmute caller ( PUT ) Caller List Get list of callers ( GET ) Add caller (dialout) ( POST )
  10. 10. Partial updates <ul><li>  WHY? </li></ul><ul><li>Efficiency: Large resources </li></ul><ul><li>Concurrency: Multiple people changing at once </li></ul><ul><li>  Approaches used: </li></ul><ul><li>Overloaded POST - One of operations are bad :( </li></ul><ul><li>Split up resource - End up with unnatural resource divisions </li></ul>
  11. 11. The PATCH Verb <ul><li>New HTTP verb </li></ul><ul><li>Partially updates a document </li></ul><ul><li>Neither idempotent nor safe </li></ul><ul><li>Patch format unspecified </li></ul><ul><li>http://tools.ietf.org/html/rfc5789 </li></ul>
  12. 12. JSONPatch    <ul><li>A patch format for JSON documents </li></ul><ul><li>http://tools.ietf.org/html/draft-pbryan-json-patch-0 </li></ul><ul><li>  [ </li></ul><ul><li>  { &quot;remove&quot;: &quot;/a/b/c&quot; }, </li></ul><ul><li>  { &quot;add&quot;: &quot;/a/b/c&quot;, &quot;value&quot;: &quot;foo&quot; }, </li></ul><ul><li>  { &quot;replace&quot;: &quot;/a/b/c&quot;, &quot;value&quot;: &quot;bar&quot; } </li></ul><ul><li>  ] </li></ul><ul><li>My new Javascript JSONPatch implementation! </li></ul><ul><li>https://github.com/dharmafly/jsonpatch.js </li></ul>
  13. 13. Thanks for listening! Questions? @almostobsolete
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×