如何提交RESTful部分更新? [英] How to submit RESTful partial updates?

查看:272
本文介绍了如何提交RESTful部分更新?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

"RESTful Web Services"的作者Sam Ruby似乎反对使用HTTP PUT进行部分更新:

Sam Ruby, author of "RESTful Web Services" seems to come out against the use of HTTP PUT for partial updates: http://intertwingly.net/blog/2008/02/15/Embrace-Extend-then-Innovate

尚不清楚应该如何进行部分更新.正如我在他的博客底部附近评论的那样,尚不清楚使用HTTP PATCH比使用针对HTTP PUT的补丁文档"有什么好处.

What isn't clear is how partial updates should take place. As I commented near the bottom of his blog, it isn't clear how using HTTP PATCH is any better than using a "patch document" against HTTP PUT.

值得注意的是,尽管Sam反对滥用HTTP PUT,但他似乎也不主张使用HTTP PATCH.

It is worth noting that although Sam comes out against misusing HTTP PUT he doesn't seem to advocate the use of HTTP PATCH either.

一个人应该如何提交RESTful部分更新?

How should one submit RESTful partial updates?

推荐答案

从您引用的博客文章中的评论中可以看出,尚无商定的进行部分更新的方法.如果像Sam Ruby,Joe Gregario,Mark Nottingham,Mark Pilgrim,Bill dehÓra这样的重量级人物无法达成协议,我们会有什么希望.

As you can see from the comments in the blog post you referenced there is no agreed upon way to do partial updates. If heavyweights like Sam Ruby, Joe Gregario, Mark Nottingham, Mark Pilgrim, Bill de hÓra, etc cannot come to an agreement, what hope do we have.

就我而言,我不会太担心.创建适合您的部分更新媒体类型,使用PATCH表示您的意图,并在最终就通用媒体类型达成协议后,更改服务器以接受两种格式.

As far as I am concerned, I wouldn't worry too much. Create a partial update media type that works for you, use PATCH to indicate your intent and when agreement is finally reached on a general purpose media type, change your server to accept both formats.

要庆幸的是,如果您的REST api犯下的最严重的错误是滥用PUT/PATCH,那么您做得还不错.

Be thankful that if the worst sin your REST api commits is abusing PUT/PATCH then you are doing pretty well.

这篇关于如何提交RESTful部分更新?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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