intridea/grape — pull request #69 by jwkoelewijn (2011-11-11 12:49:19+00:00)
Title: Added versioning based on accept headers

To call a method on a specific API version, instead of using

GET ///action, one could use

GET //action, while supplying an HTTP Accept header:
application/vnd.-+

This way it is possible to keep the URL RESTful

To use this functionality one would use:
class MyAPI < Grape::API
vendor 'grapeinc'
version 'v1.1'

get '/someaction' do
{:hello => 'world'}
end
end

To call this api, one would, for instance do
curl http://localhost:9292/someaction -H "Accept: application/vnd.grapeinc-v1.1+json"