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

前端 未结 22 2208
长情又很酷
长情又很酷 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 04:14

    I prefer using singular form for both simplicity and consistency.

    For example, considering the following url:

    /customer/1

    I will treat customer as customer collection, but for simplicity, the collection part is removed.

    Another example:

    /equipment/1

    In this case, equipments is not the correct plural form. So treating it as a equipment collection and removing collection for simplicity makes it consistent with the customer case.

提交回复
热议问题