REST URI convention - Singular or plural name of resource while creating it

前端 未结 22 2157
长情又很酷
长情又很酷 2020-12-02 03:35

I\'m new to REST and I\'ve observed that in some RESTful services they use different resource URI for update/get/delete and Create. Such as

  • Create - using
22条回答
  •  离开以前
    2020-12-02 03:57

    Have a look at Google's API Design Guide: Resource Names for another take on naming resources.

    In short:

    • Collections are named with plurals.
    • Individual resources are named with a string.
    |--------------------------+---------------+-------------------+---------------+--------------|
    | API Service Name         | Collection ID | Resource ID       | Collection ID | Resource ID  |
    |--------------------------+---------------+-------------------+---------------+--------------|
    | //mail.googleapis.com    | /users        | /name@example.com | /settings     | /customFrom  |
    | //storage.googleapis.com | /buckets      | /bucket-id        | /objects      | /object-id   |
    |--------------------------+---------------+-------------------+---------------+--------------|
    

    It's worthwhile reading if you're thinking about this subject.

提交回复
热议问题