API Versioning

未匹配的标注

Since Laravel does not support API versioning, apiato provide a very easy way to implement versioning for your API.

How it works

Create:

When creating a new API endpoint, specify the version number in the route file name following this naming format {endpoint-name}.{version-number}.{documentation-name}.php.

Example:

  • MakeOrder.v1.public.php
  • MakeOrder.v2.public.php
  • ListOrders.v1.private.php
    Use:

Automatically the endpoint inside that route file will be accessible by adding the version number to the URL.

Example:

  • http://api.apiato.develop/v1/register
  • http://api.apiato.develop/v1/orders
  • http://api.apiato.develop/v2/stores/123

Version the API in header instead of URL

First remove the URL version prefix:
1、Edit app/Ship/Configs/apiato.php, set prefix to 'enable_version_prefix' => 'false',.
2、Implement the Header versioning anyway you prefer. (this is not implemented in Apiato yet. Consider a contribution).

本文章首发在 LearnKu.com 网站上。

上一篇 下一篇
《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
讨论数量: 0
发起讨论 只看当前版本


暂无话题~