REST动词 - 这约定"正确" [英] REST verbs - which convention is "correct"

查看:172
本文介绍了REST动词 - 这约定"正确"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我早已进入实施REST服务(上如果该事项是Windows CE平台)和我开始了使用的 IBM的总体使用POST创建(插入)的定义和PUT用于更新。

I'm well into implementing a REST service (on a Windows CE platform if that matters) and I started out using IBM's general definitions of using POST for creating (INSERTs) and PUT for updating.

现在我已经跨越 Sun的定义这是完全相反的运行。所以我的问题是,这是普遍接受的定义?或者甚至有一个?

Now I've run across Sun's definitions which are exactly the opposite. So my question is, which is the "generally accepted" definition? Or is there even one?

推荐答案

使用PUT来创建资源的缺点是,该客户端具有提供
唯一的ID重新presents它正在创建的对象。而它通常可能为客户端
产生这种独特的ID,大多数应用程序设计者preFER他们的服务器(通常
通过他们的数据库)创建此ID。在大多数情况下,我们希望
我们的服务器来控制资源ID的生成。那么我们该怎么办?我们可以切换
使用而不是PUT POST。

The disadvantage of using PUT to create resources is that the client has to provide the unique ID that represents the object it is creating. While it usually possible for the client to generate this unique ID, most application designers prefer that their servers (usually through their databases) create this ID. In most cases we want our server to control the generation of resource IDs. So what do we do? We can switch to using POST instead of PUT.

所以:
把=更新

So: Put = UPDATE

邮政= INSERT

Post = INSERT

这篇关于REST动词 - 这约定"正确"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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