https://github.com/dblock/grape-on-rack-v1-inside-v2
Demonstrate versioning fallback in Grape.
https://github.com/dblock/grape-on-rack-v1-inside-v2
Last synced: 9 months ago
JSON representation
Demonstrate versioning fallback in Grape.
- Host: GitHub
- URL: https://github.com/dblock/grape-on-rack-v1-inside-v2
- Owner: dblock
- Created: 2013-07-19T15:45:21.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2024-02-29T00:37:07.000Z (over 2 years ago)
- Last Synced: 2024-12-28T21:05:43.995Z (over 1 year ago)
- Language: Ruby
- Size: 13.7 KB
- Stars: 13
- Watchers: 4
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Grape API w/ Versioning Fallback
================================
[](http://travis-ci.org/dblock/grape-on-rack-v1-inside-v2)
A [Grape](http://github.com/intridea/grape) API mounted on Rack with two versions where `v2` builds incrementally on top of `v1`. In this example the `only_in_v1` method is only implemented on version `v1`, the root method is implemented on both versions, etc.
Run
---
```
$ bundle install
$ rackup
```
Try
---
```
# without a version
curl http://localhost:9292/
{"version":"v2"}
curl http://localhost:9292/only_in_v1
{"only_in_v1":"true"}
curl http://localhost:9292/in_both_v1_and_v2
{"in_both_v1_and_v2":"v2"}
# version v2 (current)
Implemented in v2.
curl http://localhost:9292 -H "Accept:application/vnd.acme-v2+json"
{"version":"v2"}
Implemented in v1 and inherited by v2.
curl http://localhost:9292/only_in_v1 -H "Accept:application/vnd.acme-v2+json"
{"only_in_v1":"true"}
Implemented in v2.
curl http://localhost:9292/only_in_v2 -H "Accept:application/vnd.acme-v2+json"
{"only_in_v2":"true"}
curl http://localhost:9292/in_both_v1_and_v2 -H "Accept:application/vnd.acme-v2+json"
{"in_both_v1_and_v2":"v2"}
# version v1 (old)
curl http://localhost:9292 -H "Accept:application/vnd.acme-v1+json"
{"version":"v1"}
curl http://localhost:9292/only_in_v1 -H "Accept:application/vnd.acme-v1+json"
{"only_in_v1":"true"}
curl http://localhost:9292/in_both_v1_and_v2 -H "Accept:application/vnd.acme-v1+json"
{"in_both_v1_and_v2":"v1"}
```