API Versioning for Rails Routes

前端 未结 7 719
独厮守ぢ
独厮守ぢ 2020-12-04 04:12

I\'m trying to version my API like Stripe has. Below is given the latest API version is 2.

/api/users returns a 301 to /api/v2/users

<
7条回答
  •  忘掉有多难
    2020-12-04 05:10

    I'm not a big fan of versioning by routes. We built VersionCake to support an easier form of API versioning.

    By including the API version number in the filename of each of our respective views (jbuilder, RABL, etc), we keep the versioning unobtrusive and allow for easy degradation to support backwards compatibility (e.g. if v5 of the view doesn't exist, we render v4 of the view).

提交回复
热议问题