在服务器上执行的操作的RESTful什么HTTP请求? [英] What RESTful HTTP request for executing actions on the server?

查看:192
本文介绍了在服务器上执行的操作的RESTful什么HTTP请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我已经建立了一个宁静的服务器API。它的某些部分是不是控制资源,我无法绘制相关的URL + HTTP的方法在服务器上执行的操作。

I have a RESTFul server API which I've built. Some parts of it is not controlling resources and I'm having trouble mapping the relevant URL + HTTP-method to the actions that are executed on the server.

例如。我可以备份服务器上的每个资源与 POST /备份,但我不知道这是否是最合适的映射。怎么样一个单一的资源?我应该指定: POST /备份/ ID 或声明id作为一个变量,我送: POST /备份< ID>

e.g. I can backup every resource on the server with POST /backup, but I'm not sure if this the most appropriate mapping. What about a single resource? Should I specify it with: POST /backup/id or by declaring the id as a variable that I send: POST /backup <id>

请给我如何构建一些提示这个最适当使我的API是容易掌握的。

Please give me some tips on how to structure this most appropriately so that my API is easy to grasp.

推荐答案

这取决于如果你创​​建数据库的新备份对象每次你打电话,或者如果你有很多备份对象(即备份不同的文件,例如)持有只有最后一个值。

This depends if you create a new backup object on database each time you call, or if you have many backup objects (that is, backups for different files, for example) that hold only the last value.

POST /备份用于创建一个新的对象,所以正确答案,如果你总是创建一个新的备份。

POST /backups is used to create a new object, and so the correct answer if you always create a new backup.

PUT /备份/ ID 如果你是在同一个对象更新您的备份数据。

PUT /backups/id if you are updating your backup data in the same object.

这篇关于在服务器上执行的操作的RESTful什么HTTP请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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