28
Copyright 2010, Intridea Inc. All Rights Reserved. RESTful API On Grape [email protected] 2013/07/27 @XianOpenParty

Restful API On Grape

Embed Size (px)

DESCRIPTION

a topic I shared in Xi'an OpenParty 2013/07/27

Citation preview

Page 1: Restful API On Grape

Copyright 2010, Intridea Inc. All Rights Reserved.

RESTful API On Grape

[email protected] 2013/07/27 @XianOpenParty

Page 2: Restful API On Grape

Copyright 2010, Intridea Inc. All Rights Reserved.

Introduction

王要弟 == Andy Wang WangYaodi.com

Senior Ruby/Rails Enginner @intridea Weibo/Twitter/Github/RubyChina: @yorzi

Page 3: Restful API On Grape

Copyright 2010, Intridea Inc. All Rights Reserved.

What’s Grape?

Page 4: Restful API On Grape

Copyright 2010, Intridea Inc. All Rights Reserved.

Generalized Rapid APIs Erector

https://github.com/intridea/grape/blob/master/README.md

Page 5: Restful API On Grape

Copyright 2010, Intridea Inc. All Rights Reserved.

“An opinionated micro-framework

for creating RESTful APIs in Ruby”

Page 6: Restful API On Grape

Copyright 2010, Intridea Inc. All Rights Reserved.

REpresentational State Transfer

http://www.ruanyifeng.com/blog/2011/09/restful.html

Page 7: Restful API On Grape

Copyright 2010, Intridea Inc. All Rights Reserved.

Grape APIs are Rack applications

Page 8: Restful API On Grape

Copyright 2010, Intridea Inc. All Rights Reserved.

http://guides.rubyonrails.org/rails_on_rack.html

Page 9: Restful API On Grape

Copyright 2010, Intridea Inc. All Rights Reserved.

Basic API

Page 10: Restful API On Grape

Copyright 2010, Intridea Inc. All Rights Reserved.

Page 11: Restful API On Grape

Copyright 2010, Intridea Inc. All Rights Reserved.

Add Prefix

Page 12: Restful API On Grape

Copyright 2010, Intridea Inc. All Rights Reserved.

Add Namespace

Page 13: Restful API On Grape

Copyright 2010, Intridea Inc. All Rights Reserved.

Add Version

Page 14: Restful API On Grape

Copyright 2010, Intridea Inc. All Rights Reserved.

Authentication

Page 15: Restful API On Grape

Copyright 2010, Intridea Inc. All Rights Reserved.

Use Helpers

Page 16: Restful API On Grape

Copyright 2010, Intridea Inc. All Rights Reserved.

Raise Error

Page 17: Restful API On Grape

Copyright 2010, Intridea Inc. All Rights Reserved.

Exception Handling

Page 18: Restful API On Grape

Copyright 2010, Intridea Inc. All Rights Reserved.

JSONP & CORS

Page 19: Restful API On Grape

Copyright 2010, Intridea Inc. All Rights Reserved.

Rabl Template

Page 20: Restful API On Grape

Copyright 2010, Intridea Inc. All Rights Reserved.

Cookies

Page 21: Restful API On Grape

Copyright 2010, Intridea Inc. All Rights Reserved.

Redirecting

Page 22: Restful API On Grape

Copyright 2010, Intridea Inc. All Rights Reserved.

Logging

Page 23: Restful API On Grape

Copyright 2010, Intridea Inc. All Rights Reserved.

https://github.com/intridea/grape/blob/master/README.md

More Features

Page 24: Restful API On Grape

Copyright 2010, Intridea Inc. All Rights Reserved.

Run Rack App

Page 25: Restful API On Grape

Copyright 2010, Intridea Inc. All Rights Reserved.

Work with Rails

Page 26: Restful API On Grape

Copyright 2010, Intridea Inc. All Rights Reserved.

Resources https://github.com/intridea/grape/wiki

Page 27: Restful API On Grape

Copyright 2010, Intridea Inc. All Rights Reserved.

Question?

Page 28: Restful API On Grape

Copyright 2010, Intridea Inc. All Rights Reserved.

Thank You!