1

我有一个 RESTful API。DELETE /Collection/<Object-ID>将删除指定的对象。我们不会在内部删除对象。它只会标记为已删除。

现在需要输入删除评论。REST 怎么可能做到这一点?

4

2 回答 2

3

You have many options (as outlined in this question), but none of them are really considered standard practice. I personally would avoid using custom HTTP headers, but then you might run into trouble with certain HTTP implementations disallowing (or even ignoring) request bodies when sending DELETEs.

于 2013-11-14T17:50:09.363 回答
0

您可以在来自客户端的请求上添加自定义 http 标头,然后从服务器读取它。

编辑:

带有自定义标头的请求示例:

DELETE /path/to/resource HTTP/1.1
Host: localhost:8080
Accept: */*
Delete-Comment: not needed anymore

回复:

HTTP/1.1 410 Gone
Date: Thu, 14 Nov 2013 13:56:26 GMT
Content-Length: 0

请注意,不推荐使用 X-Headers:自定义 HTTP 标头:命名约定

于 2013-11-14T13:39:51.923 回答