如圖所示愕提,在編寫api時(shí)會(huì)涉及到N多版本。
此時(shí)除了在route文件夾中新建路由時(shí),還需修改accept中的版本胀葱。<分離路由:www.reibang.com/p/81918383386f>
客戶端傳了Accept : application/vnd.musikid.vX+json的情況懦底,把X當(dāng)成請(qǐng)求版本號(hào)唇牧,否則使用默認(rèn)的v1
如果以上你都編寫完畢,運(yùn)行時(shí)出現(xiàn)以下情況的話:
此時(shí)你需要修改配置文件中API_VERSION的版本號(hào)聚唐。修改完畢執(zhí)行php artisan config:cache
“ This version is the default version of your API and is used as a fallback in several circumstances whenever a version is not supplied. This version is also used as a default version for when generating API documentation. ”
運(yùn)行測試成功!