Your SlideShare is downloading. ×
0
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
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

The Grapes of Rapid (RubyConf 2010)

3,974

Published on

Talk about Grape, a rapid API development framework for Ruby. Presented at RubyConf 2010.

Talk about Grape, a rapid API development framework for Ruby. Presented at RubyConf 2010.

Published in: Technology
0 Comments
7 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,974
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
40
Comments
0
Likes
7
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. The Grapes of Rapid Michael Bleigh, RubyConf 2010
  • 2. @mbleigh @intridea
  • 3. confask.heroku.com
  • 4. This is not the talk I wanted.
  • 5. CDD
  • 6. Conference Driven Development
  • 7. Deliver Promise Me
  • 8. Motivation
  • 9. Ruby makes hard things easy
  • 10. But APIs still aren’t easy
  • 11. APIs in Rails are too entangled
  • 12. APIs in Sinatra are too manual
  • 13. Why can’t APIs have their own framework?
  • 14. #newtwitter
  • 15. Grape
  • 16. Generalized Rapid API Erector
  • 17. Something that sounds like API... ape grapegravy
  • 18. High Level
  • 19. Built for ease of development.
  • 20. Sinatra-inspired.
  • 21. Just works.
  • 22. What does it do?
  • 23. What does it do now?
  • 24. Basics
  • 25. require 'grape' class MyAPI < Grape::API get 'hello' do {:hello => 'world'} end end GET /hello {“hello”:”world”}
  • 26. JSON Serialization
  • 27. •Look for #serializable_hash •Look for #to_json •Then tries to encode the object directly •Other formats coming soon With Returned Value...
  • 28. Prefixing
  • 29. class MyAPI < Grape::API prefix 'api' get 'hello' do {:hello => 'world'} end end GET /hello 404 Not Found GET /api/hello {“hello”:”world”}
  • 30. Versioning
  • 31. class MyAPI < Grape::API prefix 'api' version 'v1' get 'hello' do {:version => version} end end GET /api/v1/hello {“version”:”v1”} GET /api/v2/hello 404 API Version Not Found
  • 32. Namespacing
  • 33. class MyAPI < Grape::API namespace :admin do namespace 'metrics' do get do {:clicks => Click.count} end get '/:date' do {:clicks => Click.for_date(params[:date]).count} end end end end GET /admin/metrics {“clicks”:235343} GET /admin/metrics/2010-11-13 {“clicks”:5392}
  • 34. Stackable Configuration
  • 35. Basic Auth
  • 36. class MyAPI < Grape::API get 'open' do "Hello." end namespace :admin do http_basic do |u,p| u == 'admin' && p == ENV['ADMIN_PASSWORD'] end namespace 'metrics' do get do {:clicks => Click.count} end end end end GET /admin/metrics 401 Unauthorized admin:somepassword GET /admin/metrics {“clicks”:235343}
  • 37. Helpers
  • 38. class MyAPI < Grape::API helpers do def current_user User.find_by_token(params[:token]) end end get '/me' do current_user end end GET /me?token=12ab312df {“screen_name”:”mbleigh”}
  • 39. Erroring
  • 40. class MyAPI < Grape::API helpers do def current_user @current_user ||= User.find_by_token(params[:token]) end end get '/me' do error!("401 Unauthorized", 401) unless current_user current_user end end GET /me?token=invalidtoken 401 Unauthorized
  • 41. What will it do soon?
  • 42. Documentation Generation
  • 43. Content Negotiation
  • 44. OAuth 1.0/2.0
  • 45. Multiple Files
  • 46. Plugin System
  • 47. Vaporware
  • 48. Streaming APIs
  • 49. PubSubHubBub
  • 50. Presenters
  • 51. Rate Limiting
  • 52. Internal API
  • 53. ConfAsk: Grape In Action
  • 54. Questions? gem install grape github.com/intridea/grape

×