Restful way for deleting a bunch of items

后端 未结 8 1130
栀梦
栀梦 2020-12-04 05:26

In wiki article for REST it is indicated that if you use http://example.com/resources DELETE, that means you are deleting the entire collection.

If you use http://ex

8条回答
  •  醉酒成梦
    2020-12-04 06:09

    I think rojoca's answer is the best so far. A slight variation might be, to do away with the javascript confirm on the same page, and instead, create the selection and redirect to it, showing a confirm message on that page. In other words:

    From:
    http://example.com/resources/

    do a

    POST with a selection of the ID's to:
    http://example.com/resources/selections

    which, if successful, should respond with:

    HTTP/1.1 201 created, and a Location header to:
    http://example.com/resources/selections/DF4XY7

    On this page you will then see a (javascript) confirm box, which if you confirm will do a request of:

    DELETE http://example.com/resources/selections/DF4XY7

    which, if successful, should respond with: HTTP/1.1 200 Ok (or whatever is appropriate for a successful delete)

提交回复
热议问题