简体   繁体   English

张贴在REST API设计中

[英]Post in REST API design

I've been under the impression that Post in Rest means "Create". 我一直觉得,“休息中发布”的意思是“创建”。 But after reading up on the spec http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.5 但是,请先阅读规范http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.5

It seems like it can be more than just Create? 似乎不仅可以创建吗? That was also stated by Stormpath in their screencasts on rest api design. Stormpath在他们关于其余api设计的屏幕录像中也指出了这一点。

According to Stormpath, Post means "Process" , which can be pretty much anything. 根据Stormpath的说法,Post的意思是“ Process”,几乎可以是任何东西。 Is that the correct way to see it? 那是正确的观看方式吗?

I can trigger custom actions for my resources using Post? 我可以使用Post触发资源的自定义操作吗?

In theory, a POST request should attempt to create or modify some resource on the server. 从理论上讲,POST请求应尝试在服务器上创建或修改某些资源。 As @Tichodroma pointed out, an idempotent request will affect this change only the first time it is sent, but otherwise what's important is that some state on the server will be changed by the request. 正如@Tichodroma指出的那样,幂等请求仅在第一次发送时才会影响此更改,但是重要的是,请求上的服务器状态会更改

More practically. 更实际地。 POST requests are often used when the request payload is too large to fit into a GET URI (eg a large file upload). 当请求有效负载太大而无法放入GET URI (例如,上传大文件)时,通常会使用POST请求。 This is usually an intentional breach of HTTP standards to avoid a 414 Request-URI Too Long response. 通常,这是故意违反HTTP标准,以避免414 Request-URI Too Long响应。

In terms of verbiage, I don't know if I like "process", because even a GET request will usually be "processed" to determine the resource to return. 就词汇而言,我不知道我是否喜欢“处理”,因为即使是GET请求,通常也将被“处理”以确定要返回的资源。 The main difference in my mind is the change of some state on the server. 我的主要区别是服务器上某些状态的更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM