如何创建没有动词的 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?
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章