HTTP,RESTand the PATCH verb(accompanied by kittens)                           Thomas Parslow                          @alm...
Web servicesThe web is used by machines as well as humansWeb services are like web sites for machines                     ...
HTTP is awesome!SimpleCommon set of operationsLibraries in every language                                        Compressi...
RESTThink in nouns not verbs!Resources are nounsResources are addressable and linkedhttp://example.com/blogpost/1NOT: http...
Current main HTTP verbs              Replace!       Destroy!   Do stuff!Show!        GET              DELETE    POST      ...
Why REST?Trendy buzzwordDiscoverable, self describingAPIsLess special cases and one offsMore maintanableLess code!
Real world example:                  Telephone conference control                             Get conference details (GET)...
Real world example:                                            Telephone conference control                               ...
Real world example:         Telephone conference control                     Get conference details (GET)                 ...
Partial updates WHY?Efficiency: Large resourcesConcurrency: Multiple people changing at once Approaches used:Overloaded PO...
The PATCH VerbNew HTTP verbPartially updates a documentNeither idempotent nor safePatch format unspecifiedhttp://tools.iet...
JSONPatchA patch format for JSON documentshttp://tools.ietf.org/html/draft-pbryan-json-patch-0                            ...
Thanks for listening!Questions?                        @almostobsolete
Upcoming SlideShare
Loading in …5
×

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

4,668 views

Published on

RESTful web services and the new HTTP PATCH Verb. Plus kittens.

My Bar Camp London 9 talk

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

No Downloads
Views
Total views
4,668
On SlideShare
0
From Embeds
0
Number of Embeds
150
Actions
Shares
0
Downloads
7
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

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

  1. 1. HTTP,RESTand the PATCH verb(accompanied by kittens) Thomas Parslow @almostobsolete http://almostobsolete.net
  2. 2. Web servicesThe web is used by machines as well as humansWeb services are like web sites for machines Various ways to design web services RPC SOAP (please no)
  3. 3. HTTP is awesome!SimpleCommon set of operationsLibraries in every language Compression? Encryption? Cacheing? Http has got it covered...
  4. 4. RESTThink in nouns not verbs!Resources are nounsResources are addressable and linkedhttp://example.com/blogpost/1NOT: http://example.com/get_blogpost
  5. 5. Current main HTTP verbs Replace! Destroy! Do stuff!Show! GET DELETE POST PUT
  6. 6. Why REST?Trendy buzzwordDiscoverable, self describingAPIsLess special cases and one offsMore maintanableLess code!
  7. 7. Real world example: Telephone conference control Get conference details (GET) Lock/Unlock Record On/ Record Off End conference Conference Add caller (dialout) Get List Of CallersEvict callerMute Caller CallerUnmute caller
  8. 8. Real world example: Telephone conference control ConferenceConference{ "type": "conference", "href": "http://example.com/conferences/1", "head": { "allow": [ "GET", "DELETE", "PUT", "PATCH" ], "created_at": "2011-10-21T10:56:54Z", "related": { Caller "callers": {"href": "http://example.com/conferences/1/callers"} }, "body": { "recording": false, "locked": false Caller List }} { "type": "caller-list", "href": "http://example.com/api/v1/conferences/1/callers", Caller "head": { }, "allow": ["GET", "POST"] "body": [ { {"href": "http://example.com/conferences/1/callers/1"} "type": "caller", ] "href": "http://example.com/conferences/1/callers/1", } "head": { "allow": [ "GET", "DELETE", "PUT", "PATCH" ] }, "body": { "phone_number": "07951261227", "name": "Tom", "type": "chair", "muted": false } }
  9. 9. Real world example: Telephone conference control Get conference details (GET) Lock/Unlock (PUT) Conference Record On/ Record Off (PUT) End conference (DELETE) Get list of callers (GET) Caller List Add caller (dialout) (POST)Caller Get caller details (GET) Evict caller (DELETE) Mute Caller (PUT) Unmute caller (PUT)
  10. 10. Partial updates WHY?Efficiency: Large resourcesConcurrency: Multiple people changing at once Approaches used:Overloaded POST - One of operations are bad :(Split up resource - End up with unnatural resource divisions
  11. 11. The PATCH VerbNew HTTP verbPartially updates a documentNeither idempotent nor safePatch format unspecifiedhttp://tools.ietf.org/html/rfc5789
  12. 12. JSONPatchA patch format for JSON documentshttp://tools.ietf.org/html/draft-pbryan-json-patch-0 [ { "remove": "/a/b/c" }, { "add": "/a/b/c", "value": "foo" }, { "replace": "/a/b/c", "value": "bar" } ]My new Javascript JSONPatch implementation!https://github.com/dharmafly/jsonpatch.js
  13. 13. Thanks for listening!Questions? @almostobsolete

×