Versioning the API
This lesson will go over how to set up versioning for the API.
We'll cover the following...
At this point, we should have a route mapping using a namespace
. Our routes.rb
file should look like this:
Press + to interact
Rails.application.routes.draw do# API definitionnamespace :api, defaults: { format: :json } do# We are going to list our resources hereendend
Now it is time to set up some other constraints for versioning purposes.
API versioning is the practice of effectively managing changes to an API by creating a different version with the required changes rather than editing the one currently being used.
It would be best to get into the practice of versioning as soon as possible since it will ensure a better final structure for our API. It also gives developers who are consuming our API the opportunity to adapt ...