RESTful url to GET resource by different fields

前端 未结 3 716
刺人心
刺人心 2020-12-19 09:44

Simple question I\'m having trouble finding an answer to..

If I have a REST web service, and my design is not using url parameters, how can I specify two different k

3条回答
  •  庸人自扰
    2020-12-19 10:28

    I guess technically you could have both URI's point to the same resource (perhaps with one of them as the canonical resource) but I think you wouldn't want to do this from an implementation perspective. What if there is an overlap between IDs and names?

    It sure does seem like a good place to use query parameters, but if you insist on not doing so, perhaps you could do

    person/{ID} 
    

    and

    personByName/{Name}
    

提交回复
热议问题