英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论