老舊的 API,該如何處理?
微信搜索
逆鋒起筆關(guān)注后回復(fù)編程pdf
領(lǐng)取編程大佬們所推薦的 23 種編程資料!
廢棄 API 端點是一項非常具有挑戰(zhàn)性的工作,我們需要考慮所有依賴該 API 的客戶端,避免出現(xiàn)級聯(lián)的故障。針對該問題,有兩個新的 HTTP 頭信息草案,本文詳細(xì)闡述了該如何使用這兩個新的頭信息安全地關(guān)閉 API。
deprecated字段),并在相關(guān)的在線文檔上大聲強(qiáng)調(diào)這一點。Deprecation: true
Deprecation: Thu, 21 Jan 2021 23:59:59 GMT
Link HTTP 響應(yīng)頭信息鏈接至端點或人類易讀的文檔。在同一個Link頭信息中,我們可以包含多個這樣的鏈接,只需要使用逗號進(jìn)行分割即可(后面我們會看到一個完整的例子)。該規(guī)范定義了四個與 API 廢棄相關(guān)的鏈接:Link: <https://developer.example.com/deprecation>; rel="deprecation"; type="text/html"
Link: <https://api.example.com/v10/customers>; rel="latest-version"
Link: <https://api.example.com/v2/customers>; rel="successor-version"
Link: <https://api.example.com/v2/users/123/clients>; rel="alternate"
Sunset: Tue, 20 Jul 2021 23:59:59 GMT
Link: <http://developer.example.com/our-sunset-policy>;rel="sunset";type="text/html"
Link頭信息)。Deprecation: Thu, 21 Jan 2021 23:59:59 GMT
Sunset: Tue, 20 Jul 2021 23:59:59 GMT
Link: <https://api.example.com/v2/customers>; rel="successor-version",
<https://developer.example.com/shutting-down-customers-v1>; rel="deprecation"
https://httptoolkit.tech/blog/how-to-turn-off-your-old-apis/
這一波騷操作!把 3000 行代碼重構(gòu)成 15 行
逆鋒起筆是一個專注于程序員圈子的技術(shù)平臺,你可以收獲最新技術(shù)動態(tài)、最新內(nèi)測資格、BAT等大廠大佬的經(jīng)驗、增長自身、學(xué)習(xí)資料、職業(yè)路線、賺錢思維,微信搜索readdot關(guān)注!
支持下
評論
圖片
表情

