Querystring in REST Resource url

前端 未结 10 1727
天命终不由人
天命终不由人 2020-11-28 19:34

I had a discussion with a colleague today around using query strings in REST URLs. Take these 2 examples:

1. http://localhost/findbyproductcode/4xxheua
2. ht         


        
10条回答
  •  臣服心动
    2020-11-28 19:49

    The ending of those two URIs is not very significant RESTfully.

    However, the 'findbyproductcode' portion could certainly be more restful. Why not just http://localhost/product/4xxheau ?

    In my limited experience, if you have a unique identifier then it would look clean to construct the URI like .../product/{id} However, if product code is not unique, then I might design it more like #2.

    However, as Darrel has observed, the client should not care what the URI looks like.

提交回复
热议问题