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

Grape APIs

Grape APIs

Christopher Hein

December 18, 2012
Tweet

More Decks by Christopher Hein

Other Decks in Programming

Transcript

  1. APIs

  2. Rails

  3. Don’t really fit together.

  4. Sinatra

  5. mmm tasty...

  6. But I’m good programmer... http://threevirtues.com/ (1)

  7. Enter...

  8. Grape 0.2.0!!!

  9. [email protected]?#$%!

  10. Simple... class API < Grape::API get :users do # omitted

    for awesomeness end end
  11. Versions... class API < Grape::API version “v1” get :users do

    # omitted for awesomeness end end
  12. Helpers... class API < Grape::API helpers do def current_user User.find

    params[:id] end end # omitted for awesomeness end
  13. Multi-file... class API < Grape::API version “v1” mount API_v1 #

    omitted for awesomeness end
  14. Describing... class API < Grape::API desc "Returns users", {params:{id: {}}}

    get :users do # omitted for awesomeness end end
  15. Demo...