Your SlideShare is downloading. ×
REST, HTTP, and the PATCH verb (with kittens)
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

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

3,691
views

Published on

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

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
3,691
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
3
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. HTTP,RESTand the PATCH verb(accompanied by kittens) Thomas Parslow @almostobsolete http://almostobsolete.net
  • 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. HTTP is awesome!SimpleCommon set of operationsLibraries in every language Compression? Encryption? Cacheing? Http has got it covered...
  • 4. RESTThink in nouns not verbs!Resources are nounsResources are addressable and linkedhttp://example.com/blogpost/1NOT: http://example.com/get_blogpost
  • 5. Current main HTTP verbs Replace! Destroy! Do stuff!Show! GET DELETE POST PUT
  • 6. Why REST?Trendy buzzwordDiscoverable, self describingAPIsLess special cases and one offsMore maintanableLess code!
  • 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. 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. 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. 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. The PATCH VerbNew HTTP verbPartially updates a documentNeither idempotent nor safePatch format unspecifiedhttp://tools.ietf.org/html/rfc5789
  • 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. Thanks for listening!Questions? @almostobsolete