什么 REST PUT/POST/DELETE 调用应该按照约定返回? [英] What REST PUT/POST/DELETE calls should return by a convention?

查看:41
本文介绍了什么 REST PUT/POST/DELETE 调用应该按照约定返回?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  1. 根据REST 意识形态",PUT/POST/DELETE 请求的响应正文中应该包含哪些内容?

  1. According to the "REST ideology" what should be in the response body for a PUT/POST/DELETE requests?

返回码呢?HTTP_OK 就够了吗?

What about return codes? Is HTTP_OK enough?

这种约定的原因是什么?

What is the reason for such conventions, if any?

我找到了一篇描述 POST/PUT 差异的好帖子:POST 与 PUT但它仍然没有回答我的问题.

I've found a good post describing POST/PUT differences: POST vs PUT But it still doesn't answer my question.

推荐答案

请原谅我的浮躁,但如果您正在通过 HTTP 进行 REST,那么 RFC7231 准确描述了 GET、PUT、POST 和 DELETE 的预期行为.

Forgive the flippancy, but if you are doing REST over HTTP then RFC7231 describes exactly what behaviour is expected from GET, PUT, POST and DELETE.

更新(2014 年 7 月 3 日):
HTTP 规范有意没有定义从 POST 或 DELETE 返回的内容.规范只定义了需要定义的内容.其余的由实施者选择.

Update (Jul 3 '14):
The HTTP spec intentionally does not define what is returned from POST or DELETE. The spec only defines what needs to be defined. The rest is left up to the implementer to choose.

这篇关于什么 REST PUT/POST/DELETE 调用应该按照约定返回?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆