RESTful delete strategy

后端 未结 5 431
走了就别回头了
走了就别回头了 2021-01-11 14:12

Let\'s say I have a resource that can have two different behaviors when delete is called

  1. The resource is deleted.
  2. The resource is moved to the recycl
5条回答
  •  难免孤独
    2021-01-11 15:04

    You could also implement 2. as a POST request instead of DELETE.

    POST /myresource
    
    recycle-bin=true...
    

    As in all you're doing is updating the resource to indicate that it is in the recycle-bin.

    EDIT: changed method from PUT to POST given a PUT must enclose a complete replacement (or addition) of the resource, whereas clearly here we are only updating a part of the resource.

提交回复
热议问题