Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ccocchi/raisin
API versioning for Rails made easy
https://github.com/ccocchi/raisin
api rails ruby
Last synced: 17 days ago
JSON representation
API versioning for Rails made easy
- Host: GitHub
- URL: https://github.com/ccocchi/raisin
- Owner: ccocchi
- License: mit
- Created: 2012-10-29T11:20:25.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2017-10-27T14:07:17.000Z (about 7 years ago)
- Last Synced: 2024-03-14T23:21:45.770Z (8 months ago)
- Topics: api, rails, ruby
- Language: Ruby
- Homepage:
- Size: 50.8 KB
- Stars: 4
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: MIT-LICENSE
Awesome Lists containing this project
README
# Raisin
API versioning via the Accept header.
## Installation
Install as a gem :
```
gem install raisin
```or add directly to your `Gemfile`
```
gem 'raisin'
```## Usage
`raisin` allows you to encapsulate your routes within API versions, using a custom `Accept` header to routes them to your controller accordingly.
It uses the fact that Rails router is resolved top to bottom.
```ruby
# config/routes.rbRails.application.routes.draw do
api :v2 do
resources :users, only: :show
endapi :v1, default: true do
resources :users
get '/users/sign_in', to: 'sessions#new'
end
end
```Clients using the version `v2` will have access to all the methods from the `v1` version plus their `/users/show` routes will be overriden the the new one define in the first `api` block.
## Configuration
```ruby
Raisin.configure do |c|
c.vendor = 'mycompany' # replace with your vendor
end
```## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request