【发布时间】:2014-09-03 06:26:56
【问题描述】:
我的 REST API URL 结构类似于:
/api/contacts GET Returns an array of contacts
/api/contacts/:id GET Returns the contact with id of :id
/api/contacts POST Adds a new contact and return it with an id added
/api/contacts/:id PUT Updates the contact with id of :id
/api/contacts/:id PATCH Partially updates the contact with id of :id
/api/contacts/:id DELETE Deletes the contact with id of :id
我的问题是:
/api/contacts/:id GET
假设除了通过 ID 获取联系人之外,我还想通过唯一别名获取它。
如果我希望能够通过 ID 或别名获取联系人,那么 URI 结构应该是什么?
【问题讨论】:
标签: api rest restful-url