API Versioning with Ruby on Rails: What Gems Are the Best
Here’s an example of versioned routes from the versionist gem using the Accept Header with the versioned media type:
namespace :versionist_api do
api_version(
header: {
name: "Accept",
value: 'application/vnd.versionist_api.v2+json'
},
module: "V2",
defaults: { format: :json }
) do
resources :books, only: [:index, :create, :show, :update, :destroy]
end
api_version(
header: {
name: 'Accept',
value: 'application/vnd.versionist_api.v1+json'
},
module: 'V1',
default: true,
defaults: { format: :json }
) do
resources :books, only: [:index, :create, :show, :update, :destroy]
end
end
Full info: https://yalantis.com/blog/api-versioning-with-ruby-on-rails/
Written by Irina
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Api
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#