如何創建沒有動詞的 REST URL? - How to create REST URLs without verbs?

問題:

I'm struggling to determine how to design restful URLs.我正在努力確定如何設計寧靜的 URL。 I'm all for the restful approach of using URLs with nouns and not verbs don't understand how to do this.我完全贊成使用帶有名詞而不是動詞的 URL 的寧靜方法不明白如何做到這一點。

We are creating a service to implement a financial calculator.我們正在創建一個服務來實現金融計算器。 The calculator takes a bunch of parameters that we will upload via a CSV file.計算器需要一堆參數,我們將通過 CSV 文件上傳這些參數。 The use cases would involve:用例將涉及:

  1. Upload new parameters上傳新參數
  2. Get the latest parameters獲取最新參數
  3. Get parameters for a given business date獲取給定業務日期的參數
  4. Make a set of parameters active激活一組參數
  5. Validate a set of parameters驗證一組參數

I gather the restful approach would be to have the following type URLs:我認爲寧靜的方法是使用以下類型的 URL:

/parameters
/parameters/12-23-2009

You could achieve the first three use cases with:您可以通過以下方式實現前三個用例:

  1. POST where you include the parameter file in the post request POST,其中您在發佈請求中包含參數文件
  2. GET of first URL獲取第一個 URL
  3. GET of second URL獲取第二個 URL

But how do you do the 4th and 5th use case without a verb?但是你如何在沒有動詞的情況下完成第 4 和第 5 個用例? Wouldn't you need URLs like:你不需要像這樣的 URL:

/parameters/ID/activate
/parameters/ID/validate

?? ??


解決方案:

參考一: https://stackoom.com/question/6nDM
參考二: How to create REST URLs without verbs?
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章