Skip to content

Commit

Permalink
Merge pull request #23 from mbradshawabs/master
Browse files Browse the repository at this point in the history
Give a hint on how to setup routing when using the path strategy
  • Loading branch information
bwillis committed Feb 19, 2014
2 parents 21fb13b + 159cb0c commit 1cfb3d8
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,16 @@ request_parameter | version that is sent in the body of the request | Good for t
:http_accept_parameter | HTTP Accept header | `Accept: application/xml; version=1` [why do this?](http://blog.steveklabnik.com/posts/2011-07-03-nobody-understands-rest-or-http#i_want_my_api_to_be_versioned)
custom | takes the request object and must return an integer | lambda {|request| request.headers["HTTP_X_MY_VERSION"].to_i }

If you use the path_parameter strategy with resources routes, you will want to setup your routes.rb config file to capture the api version. You can do that in a few ways. If you have just a few api routes you might specify the path directly like this:
```
resources :cakes, path: '/api/v:api_version/cakes'
```
If you are using a lot of routes it might be better to keep them all inside a scope like this:
```
scope '/api/v:api_version' do
resources :cakes
end
```

#### Default Version

Expand Down

0 comments on commit 1cfb3d8

Please sign in to comment.