【发布时间】:2010-10-09 17:48:05
【问题描述】:
我正在设计一个 api,我希望允许用户和组保存搜索,但不确定如何最好地公开此信息。我想出了一些 URI 来公开它们:
# These are for CRUD the search definitions, not running the searches
1. /users/{username}/searches # lists the searches for a user
2. /users/{username}/searches/{search-name} # CRUD a specific user search
3. /groups/{groupname}/searches # lists the searches for a group
4. /groups/{groupname}/searches/{search-name} # CRUD a specific group search
5. /searches/{search-id|search-name}
6. /searches/group/{groupname}/{search-name}
7. /searches/user/{username}/{search-name}
我认为没有权利公开所有这些 URI。这意味着有两种方法可以更新或列出对用户和组的搜索:通过 /groups/search 或通过 /search/group。这也意味着更多的支持,我担心会产生细微的差异。
搜索可以是数据库中的独立记录,与特定用户或组无关(例如,默认系统搜索或上下文相关搜索)。
因为搜索可以是独立的,所以将它们公开为/users/searches 和/groups/searches 感觉不对。同时,如果我在想,“鲍勃的搜索是什么?”我首先会想到/users/bob/searches,因为从逻辑上讲,它的bob's 搜索。同样,如果我想备份 bob 的帐户,他的所有个人信息都应该在 /users/bob 下。
那么,有没有人建议哪种方式更受欢迎,和/或对他们来说效果很好(或效果不佳)?
【问题讨论】: