Skip to content

Commit 8c8bb01

Browse files
author
Jerry Cheung
committed
update README: default versioning strategy uses
http accept header
1 parent 14b477c commit 8c8bb01

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

README.markdown

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Grape APIs are Rack applications that are created by subclassing `Grape::API`. B
1515

1616
```ruby
1717
class Twitter::API < Grape::API
18-
version '1'
18+
version 'v1', :using => :header, :vendor => 'twitter', :format => :json
1919

2020
helpers do
2121
def current_user
@@ -68,10 +68,18 @@ run Twitter::API
6868

6969
And would respond to the following routes:
7070

71-
GET /1/statuses/public_timeline(.json)
72-
GET /1/statuses/home_timeline(.json)
73-
GET /1/statuses/show/:id(.json)
74-
POST /1/statuses/update(.json)
71+
GET /statuses/public_timeline(.json)
72+
GET /statuses/home_timeline(.json)
73+
GET /statuses/show/:id(.json)
74+
POST /statuses/update(.json)
75+
76+
Versioning is handled with HTTP Accept head by default, but can be configures
77+
to [use different
78+
strategies](https://github.com/intridea/grape/wiki/API-Versioning). For
79+
example, to request the above with a version, you would make the following
80+
request:
81+
82+
curl -H Accept=application/vnd.twitter-v1+json http://localhost:9292/statuses/public_timeline
7583

7684
Serialization takes place automatically. For more detailed usage information, please visit the [Grape Wiki](http://github.com/intridea/grape/wiki).
7785

0 commit comments

Comments
 (0)