You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.markdown
+14-5Lines changed: 14 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ Grape is a REST-like API micro-framework for Ruby. It is built to complement exi
8
8
Grape is available as a gem, to install it just install the gem:
9
9
10
10
gem install grape
11
-
11
+
12
12
## Basic Usage
13
13
14
14
Grape APIs are Rack applications that are created by subclassing `Grape::API`. Below is a simple example showing some of the more common features of Grape in the context of recreating parts of the Twitter API.
@@ -57,20 +57,20 @@ Grape APIs are Rack applications that are created by subclassing `Grape::API`. B
57
57
end
58
58
end
59
59
end
60
-
60
+
61
61
This would create a Rack application that could be used like so (in a Rackup config.ru file):
62
62
63
63
run Twitter::API
64
-
64
+
65
65
And would respond to the following routes:
66
66
67
67
GET /1/statuses/public_timeline(.json)
68
68
GET /1/statuses/home_timeline(.json)
69
69
GET /1/statuses/show/:id(.json)
70
70
POST /1/statuses/update(.json)
71
-
71
+
72
72
Serialization takes place automatically. For more detailed usage information, please visit the [Grape Wiki](http://github.com/intridea/grape/wiki).
73
-
73
+
74
74
## Raising Errors
75
75
76
76
You can raise errors explicitly.
@@ -117,6 +117,15 @@ You can also rescue specific exceptions with a code block and handle the Rack re
You can test a Grape API with RSpec. Tests make HTTP requests, therefore they must go into the `spec/request` group. You may want your API code to go into `app/api` - you can match that layout under `spec` by adding the following in `spec/spec_helper.rb`.
0 commit comments