do you do rest
play

Do You Do REST? Subbu Allamaraju Yahoo! Inc QCon San - PowerPoint PPT Presentation

Do You Do REST? Subbu Allamaraju Yahoo! Inc QCon San Francisco Nov 3-5, 2010 2 Take-away Interfaces for interoperability 3 Do you do


  1. Do ¡You ¡Do ¡REST? ¡ Subbu ¡Allamaraju ¡ Yahoo! ¡Inc ¡ QCon ¡San ¡Francisco ¡Nov ¡3-­‑5, ¡2010 ¡

  2. 2 ¡

  3. Take-­‑away ¡ Interfaces ¡for ¡interoperability ¡ 3 ¡

  4. Do ¡you ¡do ¡REST? ¡ … ¡we ¡don’t ¡do ¡pure ¡REST ¡ 4 ¡

  5. But ¡where ¡did ¡REST ¡come ¡from? ¡ 5 ¡

  6. Quality ¡AJributes ¡ • Performance ¡ • Scalability ¡ • Simplicity ¡ – SeparaLon ¡of ¡concerns ¡ • Modifiability ¡ – Evolvability, ¡extensibility, ¡customizability, ¡configurability, ¡ reusability ¡ • Portability ¡ – By ¡making ¡a ¡constrained ¡set ¡of ¡choices ¡for ¡represenLng ¡data ¡and ¡ code ¡ • Reliability ¡ – Avoiding ¡single ¡points ¡of ¡failure, ¡redundancy, ¡monitoring ¡ 6 ¡

  7. • IdenLficaLon ¡of ¡ resources ¡ • ManipulaLon ¡via ¡ representaLons ¡ • Self-­‑descripLve ¡ Constraints ¡ messages ¡ • Hypermedia ¡as ¡the ¡ engine ¡of ¡applicaLon ¡ state ¡ • Code ¡on ¡demand ¡ 7 ¡

  8. • URIs ¡as ¡resource ¡ idenLfiers ¡ • HTTP ¡as ¡the ¡uniform ¡ interface ¡ ApplicaLon ¡ • MIME-­‑like ¡message ¡ format ¡ to ¡the ¡web ¡ • Hypertext ¡(controls ¡ like ¡forms ¡and ¡links) ¡ • Code ¡on ¡demand ¡ 8 ¡

  9. Human-­‑web ¡ Scalable ¡and ¡pervasive ¡ Network-­‑effect ¡in ¡acLon ¡ 9 ¡

  10. Machine-­‑web ¡ Server ¡ ApplicaLon ¡and ¡impact ¡ with ¡mixed ¡results ¡ Client ¡ 10 ¡

  11. Level ¡3: ¡ ¡Hypermedia ¡ MarLn ¡Fowler’s ¡ “Glory ¡of ¡REST” ¡ Level ¡2: ¡ ¡Many ¡URIs, ¡many ¡HTTP ¡methods ¡ Level ¡1: ¡ ¡Many ¡URIs, ¡one ¡HTTP ¡method ¡ Level ¡0: ¡ ¡One ¡URI, ¡one ¡HTTP ¡method ¡ Leonard ¡Richardson’s ¡Maturity ¡Model ¡ 11 ¡

  12. Q. ¡What ¡is ¡the ¡contract? ¡ ¡ Q. ¡What ¡needs ¡to ¡be ¡governed? ¡ Q. ¡How ¡to ¡deal ¡with ¡versioning? ¡ Q. ¡How ¡to ¡make ¡services ¡extensible? ¡ 12 ¡

  13. Server ¡ Server ¡ Server ¡ Server ¡ ~ ¡ ~ ¡ ~ ¡ ~ ¡ ~ ¡ ~ ¡ ~ ¡ Each ¡with ¡its ¡own ¡set ¡of ¡barriers ¡ ~ ¡ ~ ¡ Client ¡ Client ¡ Client ¡ Client ¡ Inconsistent ¡URIs, ¡IDs, ¡HTTP ¡ usage, ¡security, ¡formats, ¡… ¡ 13 ¡

  14. http://foo.com/person/1234/address/6789 ¡ http://bar.com/user?id=1234&filter=address ¡ http://baz.com/user;id=1234/address;id=6789 ¡ 14 ¡

  15. <comment ¡id=“1234” ¡posted_by=“user01”> ¡ ¡ ¡<text>…</text> ¡ ¡ ¡… ¡ </comment> ¡ { ¡ ¡ ¡ ¡“id” ¡: ¡“user01”, ¡ ¡ ¡ ¡“name” ¡: ¡“Joe”, ¡ ¡ ¡ ¡“locaLon” ¡: ¡{ ¡ ¡ ¡ ¡ ¡ ¡ ¡“lat” ¡: ¡“…”, ¡ ¡ ¡ ¡ ¡ ¡ ¡“lng” ¡: ¡“…” ¡ ¡ ¡ ¡ ¡} ¡ ¡ ¡ ¡ ¡… ¡ } ¡ 15 ¡

  16. Challenge: ¡ Interoperability ¡ “…the ¡ability ¡of ¡diverse ¡systems ¡and ¡ organizaLons ¡to ¡work ¡together” ¡ [ Wikipedia ] ¡ 16 ¡

  17. What ¡is ¡the ¡interface ¡of ¡the ¡Web? ¡ 17 ¡

  18. Thinking ¡about ¡interfaces ¡ Consumers ¡ Iden%ty ¡ Fielding’s ¡ ¡ Remote-­‑as-­‑local ¡ Protocol ¡ ¡ Behavior ¡ ili%es ¡ OS ¡independence ¡ independence ¡ State ¡ Naming ¡ … ¡ Interface ¡ IDL ¡ WSDL ¡ ? ¡ Object ¡ Dist. ¡Obj. ¡ Service ¡ Resource ¡ >me ¡ 18 ¡

  19. Decentralized ¡ C/S ¡ C/S ¡ I ¡ I ¡ I ¡ I ¡ I ¡ C/S ¡ C/S ¡ I ¡ I ¡ I ¡ I ¡ I ¡ I ¡ C/S ¡ C/S ¡ I ¡ Agreements ¡among ¡disagreements ¡ 19 ¡

  20. Single ¡interface ¡ ¡ Many interfaces Most ¡given ¡+ ¡Some ¡applicaLon ¡defined ¡ Interoperability ¡= ¡ f (interfaces) ¡ ¡ 20 ¡

  21. Interface : ¡URIs ¡ 21 ¡

  22. Interface: ¡URIs ¡ [RFC ¡ ¡3986] ¡ 1. ¡Syntax ¡ {scheme}://{authority}/{path}?{query}#{frag} ¡ 2. ¡ResoluLon ¡ ¡ ¡ ¡ ¡Base: ¡http://www.example.org ¡ Relative: ¡/path?query ¡ 3. ¡NormalizaLon ¡and ¡Comparison ¡ Is ¡http://www.example.org/path?query ¡the ¡same ¡ as ¡http://example.org/path/?query ¡ 22 ¡

  23. + ¡Dereferenceable ¡ http ://www.subbu.org/blog/tag/rest ¡ http ://api.nytimes.com/svc/search/v1/ article?query=haiti&api-­‑key={api-­‑key} ¡ jar :http://mycorp.com/jars/foo.jar!/ mycorp/User.class ¡ ¡ jms :topic:Stocks.Prices ¡ 23 ¡

  24. + ¡IdenLty ¡ • IdenLfier ¡in ¡some ¡local ¡or ¡global ¡scope ¡ • Be ¡able ¡to ¡make ¡asserLons ¡ <! ¡A ¡review ¡of ¡RESTful ¡Web ¡Services ¡ ¡ ¡ ¡ ¡ ¡ ¡Cookbook ¡-­‑-­‑> ¡ <review> ¡ ¡ ¡<link ¡href=“http://amzn.com/0596801688” ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡rel=“review”/> ¡ ¡ ¡... ¡ </review> ¡ 24 ¡

  25. + ¡Hackable ¡and ¡Consistent ¡ http://api.twitter.com/version/statuses/ show/ :id.format ¡ ¡ http://api.twitter.com/1/statuses/ user_timeline . format ?user_id= :userid ¡ https://my.social.net/contacts/ userEmail ¡ http://my.social.net/videos/ username / playlists ¡ 25 ¡

  26. Interface : ¡Resources ¡ 26 ¡

  27. Interface: ¡Resources ¡ None ¡ “(T)he ¡term ¡‘resource’ ¡is ¡used ¡in ¡a ¡ general ¡sense ¡for ¡whatever ¡might ¡be ¡ idenLfied ¡by ¡a ¡URI” ¡ [RFC-­‑3986] ¡ 27 ¡

  28. + ¡Many ¡Resources ¡ • Everything ¡that ¡a ¡client ¡needs ¡has ¡a ¡URI ¡ • Consistent ¡formats ¡and ¡paJerns ¡for ¡ representaLons ¡ 28 ¡

  29. <comment> ¡ ¡ ¡<id>1234</id> ¡ ¡ ¡<user> ¡ ¡ ¡ ¡ ¡<id>user01</id> ¡ ¡ ¡ ¡ ¡<link ¡rel=“user” ¡ <user> ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡href=“...”/> ¡ ¡ ¡<id>user01</id> ¡ ¡ ¡</user> ¡ ¡ ¡<name>Joe</name> ¡ ¡ ¡<text>…</text> ¡ ¡ ¡<locaLon> ¡ ¡ ¡… ¡ ¡ ¡ ¡ ¡<lat>…</lat> ¡ </comment> ¡ ¡ ¡ ¡ ¡<lng>…</lng> ¡ ¡ ¡</locaLon> ¡ </user> ¡ 29 ¡

  30. Interface : ¡HTTP ¡ 30 ¡

  31. Interface: ¡HTTP ¡ [RFC ¡ ¡2616] ¡ 1. HTTP ¡methods ¡GET, ¡PUT, ¡POST, ¡DELETE, ¡HEAD ¡ and ¡OPTIONS ¡ Fixed ¡set ¡of ¡methods ¡lets ¡a ¡lot ¡of ¡people ¡agree ¡ and ¡support ¡them ¡– ¡a ¡key ¡for ¡interoperability ¡ 31 ¡

  32. Interface: ¡HTTP ¡ [RFC ¡ ¡2616] ¡ 2. Message ¡syntax ¡ – Headers ¡+ ¡body ¡ 3. Method ¡safety ¡ – GET, ¡HEAD, ¡OPTIONS ¡ 4. Method ¡idempotency ¡ – GET, ¡HEAD, ¡OPTIONS, ¡PUT, ¡DELETE ¡ See ¡Chapter ¡1 ¡in ¡RESTful ¡Web ¡Services ¡Cookbook ¡ 32 ¡

  33. + ¡Protocol ¡ 1. Content ¡negoLaLon ¡(?) ¡ – Accept-­‑* ¡headers ¡or ¡URIs ¡for ¡each ¡format ¡ 2. Caching ¡ – Last-­‑Modified , ¡ Cache-­‑Control ¡ 3. CondiLonal ¡requests ¡ – If-­‑Modified-­‑Since , ¡ If-­‑Unmodified-­‑ Since , ¡ If-­‑Match , ¡ If-­‑None-­‑Match ¡ 4. Custom ¡headers ¡(?) ¡ ¡ See ¡Chapters ¡7, ¡9 ¡and ¡10 ¡in ¡RESTful ¡Web ¡Services ¡Cookbook ¡ 33 ¡

  34. Interface : ¡Security ¡Protocols ¡ 34 ¡

  35. Interface: ¡Security ¡ [RFC ¡ ¡2616] ¡ • Support ¡for ¡ WWW-­‑Authenticate ¡and ¡ Authorization ¡headers ¡ 35 ¡

  36. Client ¡ Server ¡ GET ¡/foo ¡HTTP/1.1 ¡ HTTP/1.1 ¡401 ¡Unauthorized ¡ WWW-­‑Authenticate: ¡<scheme> ¡ Ley ¡to ¡ other ¡ protocols ¡ GET ¡/foo ¡HTTP/1.1 ¡ Authorization: ¡<token> ¡ HTTP/1.1 ¡2OO ¡OK ¡ 36 ¡

  37. Interoperability ¡Hurdles ¡ • Early ¡protocols ¡ – RFC ¡2617 ¡ – Poor ¡adopLon ¡ – Basic ¡auth ¡was ¡weak ¡and ¡Digest ¡auth ¡was ¡complex ¡ • Cookies ¡are ¡widely ¡interoperable, ¡but ¡poorly ¡ specified ¡ • Security ¡policies ¡within ¡corporate ¡networks ¡ are ¡oyen ¡unique ¡to ¡each ¡organizaLon ¡ 37 ¡

  38. + ¡Consistency ¡ 1. Consistent ¡HTTP ¡based ¡protocols ¡ – Basic ¡ – Oauth ¡1.0 ¡and/or ¡OAuth ¡2.0 ¡ – Custom ¡but ¡ consistent ¡ 38 ¡

  39. Interface : ¡Hypertext ¡ 39 ¡

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend