Rapid-ruby-api-on-grape
-
Upload
andy-wang -
Category
Technology
-
view
7.737 -
download
0
description
Transcript of Rapid-ruby-api-on-grape
Copyright 2010, Intridea Inc. All Rights Reserved.
Rapid Ruby API On Grape ���
[email protected] 2011/07/24
Copyright 2010, Intridea Inc. All Rights Reserved.
About Me Symbol - yorzi Details - about.me/wangyaodi Senior Engineer at Intridea Inc.
More Links: http://github.com/yorzi http://twitter.com/yorzi http://more-sites/yorzi
王要弟 Andy Wang
Copyright 2010, Intridea Inc. All Rights Reserved.
What’s Grape?
Copyright 2010, Intridea Inc. All Rights Reserved.
Copyright 2010, Intridea Inc. All Rights Reserved.
https://github.com/mbleigh https://github.com/intridea/omniauth
https://github.com/mbleigh/acts-as-taggable-on
Copyright 2010, Intridea Inc. All Rights Reserved.
Ok, BUT���What’s Grape?
Copyright 2010, Intridea Inc. All Rights Reserved.
“An opinionated ���micro-framework ���
for creating REST-like��� APIs in Ruby”
https://github.com/intridea/grape http://www.infoq.com/articles/rest-introduction
Copyright 2010, Intridea Inc. All Rights Reserved.
Ruby makes hard things easy
Copyright 2010, Intridea Inc. All Rights Reserved.
But APIs still aren’t easy
Copyright 2010, Intridea Inc. All Rights Reserved.
APIs in Rails are too entangled
Copyright 2010, Intridea Inc. All Rights Reserved.
APIs in Sinatra are too manual
Copyright 2010, Intridea Inc. All Rights Reserved.
Copyright 2010, Intridea Inc. All Rights Reserved.
Copyright 2010, Intridea Inc. All Rights Reserved.
How To Use Grape?
Copyright 2010, Intridea Inc. All Rights Reserved.
Copyright 2010, Intridea Inc. All Rights Reserved.
Remember: ���Grape APIs are
Rack applications
http://ruby.about.com/od/rack/a/What-Is-Rack.htm
Copyright 2010, Intridea Inc. All Rights Reserved.
Basic API
Copyright 2010, Intridea Inc. All Rights Reserved.
Result,���JSON Serialization
Copyright 2010, Intridea Inc. All Rights Reserved.
Add Prefix
Copyright 2010, Intridea Inc. All Rights Reserved.
Add Version ���
Copyright 2010, Intridea Inc. All Rights Reserved.
Add Namespace ���
Copyright 2010, Intridea Inc. All Rights Reserved.
Other Namespacing ���Key words
Copyright 2010, Intridea Inc. All Rights Reserved.
Add Basic Auth ���
Copyright 2010, Intridea Inc. All Rights Reserved.
Use Helpers ���
Copyright 2010, Intridea Inc. All Rights Reserved.
Raise Error ���
Copyright 2010, Intridea Inc. All Rights Reserved.
Error Details
Copyright 2010, Intridea Inc. All Rights Reserved.
How To ���Run Grape APIs?
Copyright 2010, Intridea Inc. All Rights Reserved.
Remember: ���Grape APIs are
Rack applications
Copyright 2010, Intridea Inc. All Rights Reserved.
Run As a Rack App
Run `rackup` in Rack App(API) folder
Copyright 2010, Intridea Inc. All Rights Reserved.
Grape with Rails 2.3.x
Copyright 2010, Intridea Inc. All Rights Reserved.
Grape with Rails 3.x
Copyright 2010, Intridea Inc. All Rights Reserved.
Any Future Feature?���YES!
Copyright 2010, Intridea Inc. All Rights Reserved.
Near Future
*Support for XML formatting *Multiple-file APIs (modularity)
*OAuth 1.0a and 2.0 authentication support Filters/Callbacks
https://github.com/makandra/modularity http://code.dblock.org/modularizing-a-ror-grape-api
Copyright 2010, Intridea Inc. All Rights Reserved.
Medium Future
YARD extensions for self-documenting APIs Plugin System for easy extension
Internal API Access Rate Limiting
Lifecycle Automation
Copyright 2010, Intridea Inc. All Rights Reserved.
Far Future
Streaming API support PubSubHubBub
Copyright 2010, Intridea Inc. All Rights Reserved.
Resources & References RubyConf 2010 presentation about Grape.
http://confreaks.net/videos/475-rubyconf2010-the-grapes-of-rapid
https://github.com/downloads/intridea/grape/The%20Grapes%20of%20Rapid.pdf
Example Rails implementation http://martinciu.com/2011/01/mounting-grape-api-
inside-rails-application.html
Copyright 2010, Intridea Inc. All Rights Reserved.
Demo & Sample Demo API with Sinatra App.
https://github.com/mbleigh/conf_ask http://www.arailsdemo.com/posts/30
Well Documented Sample API. https://gist.github.com/892282
Copyright 2010, Intridea Inc. All Rights Reserved.
Copyright 2010, Intridea Inc. All Rights Reserved.
Thank You!