DELETE用于删除请求资源:
The DELETE method requests that the origin server delete the resource identified by the Request-URI. This method MAY be overridden by human intervention (or other means) on the origin server. The client cannot be guaranteed that the operation has been carried out, even if the status code returned from the origin server indicates that the action has been completed successfully …
PUT用于放置或更新服务器上的资源:
The PUT method requests that the enclosed entity be stored under the supplied Request-URI. If the Request-URI refers to an already existing resource, the enclosed entity SHOULD be considered as a modified version of the one residing on the origin server. If the Request-URI does not point to an existing resource, and that URI is capable of being defined as a new resource by the requesting user agent, the origin server can create the resource with that URI …
完整规格参数:
POST http://example.com/order/1/delete
或甚至更糟
POST http://example.com/deleteOrder/id/1
有效地隧穿了通过HTTP的CRUD语义。但是动词从来不是URI的一部分。相反,HTTP已经通过HTTP方法向CRUD提供了资源(例如订单)的机制和语义。 HTTP是一种协议,而不仅仅是一些数据隧道服务。
因此,要删除网络服务器上的资源,您可以调用
DELETE http://example.com/order/1
并更新它,你会打电话
PUT http://example.com/order/1
并在PUT正文中提供更新的资源表示,供网络服务器应用。
所以,如果你正在为一个REST API构建某种客户端,你可能会发送PUT和DELETE请求。这可以是在浏览器内部构建的客户端,例如通过JavaScript发送请求,或者可以是在服务器上运行的某些工具等。
有关更多详情,请访问: