DELETE 和 UNDELETE 的 REST 约定

REST convention for DELETE and UNDELETE

想知道如何使用单个端点进行这些操作。这实际上不是删除,而是设置标志 deleted = 0 或 1 所以我正在考虑 put,如果它是实际删除,我会使用 DELETE(请确认这一点)

但是如何在服务器端区分这两个调用。

PUT /product/:id   (to delete)
PUT /product/:id   (to undelete) 

DELETE /product/:id (to delete)
DELETE /product/:id (to undelete)

编辑 我已经为产品的定期更新准备好了 PUT,假设它是名称、数量等,所以它与定期更新和取消删除有点冲突。这个也请多多指教

(因为你不能使用 PUT)我建议:

DELETE /product/:id   (to delete)
PATCH /product/:id  (to update/undelete)
// and just send a simple payload/query parameter specifying the `IsActive` bit.) 

对于 PATCH,我需要一些时间来取消删除它,因此它和字段子集的更新。在服务器上,您将拥有一个控制器并查看 http 方法 (PATCH| DELETE)