Taking a REST and being HAPI

  • 494 views
Uploaded on

Slides from J and Beyond 2013 presentation. …

Slides from J and Beyond 2013 presentation.

You have probably heard of REST and Web Services. In this presentation you will learn what they are and why they are important to the future of Joomla. You will learn why it is important for the API to be HAPI, what the HATEOAS constraint is and why developers should always keep it in mind when writing clients and servers on the new API, and why moving to a services-first design philosophy is important for everyone involved in Joomla software development.

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
494
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
0
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. and being HAPITaking a RESTChris DavenportJoomla Production Leadership Team
  • 2. Architectural Style of the Web"The World Wide Web has succeeded in largepart because its software architecture has beendesigned to meet the needs of an Internet-scale distributed hypermedia system."Fielding, Roy Thomas. Architectural Styles and the Design of Network-based Software Architectures.Doctoral dissertation, University of California, Irvine, 2000.
  • 3. Web experiences growing pains
  • 4. Web standards adjustedFielding: Analysis of network-based softwarearchitectures● Key constraints give rise to desiredproperties● Internet-scale distributed hypermediaAdjustments/corrections made● HTTP/1.1 RFC 2616● Uniform Resource Identifiers RFC 3986● and others
  • 5. Web saved! Hurray!(2008: Google reaches 1 trillion unique URLs)
  • 6. What is REST?2000: Fieldings PhD dissertation● REST (Representational State Transfer)● Architectural style for building scalable,distributed, hypermedia applications.● The architectural style that has been usedto guide the design and development ofthe World Wide Webs architecture.
  • 7. REST constraints● client-server● stateless● cache● uniform interface● layered system● code-on-demand (optional)The important point is to not unintentionallyviolate these constraints.
  • 8. Client-serverClient and server may be● developed at different times● by different people● evolving at different ratesBut they must always have aShared Understanding
  • 9. Resource-basedResources are identified by URIs:www.example.com/articles/1234Note: This might be the same resource at some point in time:www.example.com/articles/latest-news
  • 10. Manipulation of resources viarepresentationsCeci nest pas une pipeTranslation: "This is not a pipe"
  • 11. Self-descriptive messagesThere must be enough information in eachmessage for the recipient to understand it.Self-contained messages have their limits.There will always be out-of-band informationneeded to understand messages. The problemis where to draw the line.
  • 12. Hypermedia constraintHypermedia as the engine of application state● Clients drive application state by○ following hypermedia links○ or submitting forms● Clients should treat URLs as opaque○ except for URI Templates (RFC 6570)● Fielding: "Servers must have the freedom tocontrol their own namespace"○ Servers can change URIs without breaking clients
  • 13. What about Joomla?SharedcodeSiteAdminModulesWebbrowserHTMLServer (Joomla)Client
  • 14. What about Joomla?SharedcodeSiteAdminModulesWebbrowserHTMLServer (Joomla)ClientAJAXJSON
  • 15. What about Joomla?● Mobile (and other) devices● Internet of Things● Open data● Integrating business processes● Electronic Data Interchange (EDI)
  • 16. Joomla is an information siloComponents cant easilycommunicate with each other
  • 17. Joomla Hypermedia Services● Break Joomla components/modules intosmaller "services".● Services have a uniform interface○ JInput for input○ JSON, XML, HAL, etc. for output● Services communicate using media types○ application/vnd.joomla.*○ Additional constraints using schemas/profiles
  • 18. Joomla Next?ServicesDeviceServerHALHALHAPIServer (Joomla)
  • 19. application/hal+*Resource representation_embedded _linksrel hrefrel hrefrel href
  • 20. Joomla Next?ServicesSite UIAdminUIWebbrowserHTMLHTMLHALHALServer (Joomla)ClientHAPI
  • 21. Joomla Next?ServicesSite UIAdminUIWebbrowserAJAXHALHTMLHTMLHALHALServer (Joomla)ClientHAPI
  • 22. Joomla Next?ServicesSite UIAdminUIHALHALServer (Joomla)ClientWeb browserHAPI
  • 23. Joomla Next?ServicesDeviceServerHALHALServer (Joomla)CLIHALDaemonHALHAPI HAPI
  • 24. Joomla Next?ServicesUIWeb browserHTML HALServer (Joomla)ClientHAPIServicesHALAnother serverHAPIUI
  • 25. Whats inside a service?ServicesServer (Joomla)HAPICMVRAD/SDK/FoFCLIDrupal 8HAPI
  • 26. Web Services Working Grouphttp://docs.joomla.org/Web_Services_Working_Group● Web Services Specification○ currently at second draft● Sample code○ based on new MVC in Joomla 3.x○ structure allows it to be retrofitted to any componentwithout touching existing code○ articles, weblinks, categories○ can be browsed with any generic HAL client
  • 27. application/vnd.joomla.*+hal+*Resource representation_embedded _links _metarel hrefrel hrefrel href
  • 28. Hierarchy of media typesJSONHALvnd.joomla.servicevnd.joomla.listvnd.joomla.itemXMLRemember: Shared understanding
  • 29. WSWG Next Stepshttp://docs.joomla.org/Web_Services_Working_Group● Web Services Specification○ more people to read and comment● Coding○ more people to write code for a J3.x implementation○ client SDK (JavaScript and PHP versions)● Future○ more people to work on an architecture for Joomlabeyond the 3.x cycle
  • 30. Questions?Play with a demo athttp://demo.davenporttechnology.com/api/hal-browser/browser.html#http://demo.davenporttechnology.com/apiThank you for listening
  • 31. Image creditshttp://commons.wikimedia.org/wiki/File:Paris_-_Jardin_du_Luxembourg_-_le_soir.JPG License: GNUFDLhttp://en.wikipedia.org/wiki/File:Crying-girl.jpg License: CC-A-SA 2.0http://www.veezzle.com/photo/1529836/Class-of-2007-USAF-Academy-Graduation-Hat-Hurray-Toss-Thunderbird-Fly-Over License: CC-A 3.0http://en.wikiversity.org/wiki/File:Alvano-Sabina-pipe.jpg License: GNU FDLhttp://commons.wikimedia.org/wiki/File:Ralls_Texas_Grain_Silos_2010.jpg License: Public domain