Upgrade to Pro — share decks privately, control downloads, hide ads and more …

API Driven Development with Goliath

API Driven Development with Goliath

APIs Rule Everything Around Us. Its the glue that binds the internet operating system together and is partly responsible for the run-away success of a number of startups including Twitter, Facebook and Foursquare.

General purpose frameworks don’t always make for great tools when designing a Service Oriented Architecture or for building Hypermedia APIs. Sure, you can develop everything as a set of RESTful resources, but the temptation to mix presentation logic with your business logic is quite high and can lead to a cluttered and bloated codebase.

What we need is a dedicated API framework, one that speaks HTTP natively and is flexible enough to bend to the will of even the most demanding API designers.

Enter Goliath, the asynchronous ruby framework by Postrank Labs, that was created with the sole purpose of building and deploying Hypermedia APIs, ready to serve a massive amount of concurrent traffic. Built on Event Machine and Rack, this low level framework provides just enough structure and middleware to get you up and running and then gets out of your way.

In this session we’ll explore its feature set, talk a bit about good RESTful API design, and highlight some of the pros and cons of using Goliath instead of Sinatra or Rails for building your next Web Service.

Eric Marden

April 24, 2012
Tweet

More Decks by Eric Marden

Other Decks in Programming

Transcript

  1. API Driven Development
    with Goliath Eric Marden
    @xentek

    View Slide

  2. Hello, World
    {
    name: “Eric Marden”,
    twitter: “@xentek”,
    blog: “xentek.net”,
    self_link: “ericmarden.com”
    } 200 OK

    View Slide

  3. Hypermedia APIs
    REST vs Hypermedia
    Discoverable
    Cacheable
    Linkable
    HATEOAS
    API Driven Development

    View Slide

  4. Goliath
    what is it?
    how can I use it to build awesome hypermedia apis?
    how does it compare to...?
    tips, tricks, and gotchas

    View Slide

  5. Goliath
    what is it?

    View Slide

  6. Goliath
    asynchronous
    low level
    rack-based
    built on event machine (reactor pattern)
    ruby fibers
    native http parser

    View Slide

  7. Goliath
    features

    View Slide

  8. Goliath
    easy to learn
    easy to test
    rich middleware stack
    fast

    View Slide

  9. Goliath
    request cycle

    View Slide

  10. Goliath

    View Slide

  11. View Slide

  12. Goliath

    View Slide

  13. Goliath
    route map

    View Slide

  14. Goliath

    View Slide

  15. Goliath
    middleware

    View Slide

  16. View Slide

  17. Goliath
    endpoint

    View Slide

  18. View Slide

  19. Goliath
    how does it compare to…?

    View Slide

  20. Goliath
    rails
    versus

    View Slide

  21. Goliath
    sinatra
    versus

    View Slide

  22. Goliath
    tips, tricks, and gotchas

    View Slide

  23. Goliath
    models, modules, and
    objects
    OH MY

    View Slide

  24. View Slide

  25. View Slide

  26. Goliath
    configuration

    View Slide

  27. View Slide

  28. Goliath
    headers

    View Slide

  29. Goliath

    View Slide

  30. Goliath
    status codes

    View Slide

  31. View Slide

  32. Goliath
    validation

    View Slide

  33. Goliath
    Goliath::Rack::Validation::RequiredParam
    Goliath::Rack::Validation::RequiredValue
    Goliath::Rack::Validation::RequestMethod
    ...and many more

    View Slide

  34. Goliath
    error handling

    View Slide

  35. View Slide

  36. Goliath
    blocking the reactor

    View Slide

  37. Goliath
    testing

    View Slide

  38. View Slide

  39. KTHXBYE
    {
    name: “Eric Marden”,
    twitter: “@xentek”,
    blog: “xentek.net”,
    self_link: “ericmarden.com”
    } 410 GONE

    View Slide

  40. Further Reading
    http://goliath.io
    http://designinghypermediaapis.com/
    http://j.mp/rest-fielding-dissertation
    http://j.mp/api-only-apps-with-rails
    https://gimmebar.com/loves/xentek/tag/hypermedia
    http://httpstatus.es/

    View Slide