复数化的 REST 资源

huangapple go评论100阅读模式
英文:

Pluralized Rest Resources

问题

我想创建一个新的REST资源,用于在数据库中搜索实体。由于请求体中传递了复杂的条件,我必须使用POST进行请求。

我将我的资源端点创建为/search,然而,我了解到资源的名称应始终为复数形式。在这种情况下,我应该将其命名为/searches吗?我想知道/searches是否是标准的命名约定。

英文:

I want to create a new rest resources that searches an entity in database. I have to make the request as POST since there is a complex criteria passed in a request body.

I created my resource endpoint as /search, however, I learned that resources should be always pluralized. In this case, should I be naming as /searches? I want to know if /searches is a standard naming convention?

答案1

得分: 2

不,我从未听说过资源应始终使用复数形式。我会说在这种情况下应该使用 /search。例如,如果你在 Google 或者 MSN 上进行搜索,你会看到他们在搜索时使用 /search。

希望这能帮到你。

英文:

No, I have never heard that resources should always be pluralized. I would say /search is appropriate here. For example, if you do a search on google or msn, you'll see that they use /search for their searches.

Hopefully this helps.

huangapple
  • 本文由 发表于 2020年9月11日 01:53:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/63835204.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定