kab*_*ros 4 rest webserver http restful-architecture
我正在开发一个清理/过滤服务,它有一个方法接收在xml中序列化的对象列表,并应用一些过滤规则来返回这些对象的子集.
在REST-ful服务中,我应该使用什么动词来表示这种方法?我认为GET是一个很自然的选择,但是我必须将序列化的XML放在请求的主体中,但有效但感觉不正确.其他动词似乎不符合语义.
定义Service接口的好方法是什么?命名资源/清理或/过滤器似乎很奇怪主要是因为在我看到的在线示例中,它始终是名称而不是用于资源名称的动词.
Am I right to feel that REST services are better suited for CRUD operations and you start bending the rules in situations like this service? If yes, am I then making a wrong architectural choice.
I've pushed to develop this service in REST-ful style (as opposed to SOAP) for simplicity, but such awkward cases happen a lot and make me feel like I am missing something. Either choosing REST where it shouldn't be used or may be over-thinking some stuff that doesn't really matter? In that case, what really matters?
REST就是按照设计的方式使用HTTP.要RESTful考虑(标题是REST设计:):
很难给出确切的指导,因为问题不明确但希望RESTful原则上的指导和思想能让你走上正轨.如果你澄清确切的电话,我会尝试推荐API.
所以,假设你想清理复制的foos.
[GET]/foos/duplicates(或/ foos?filter = duplicates)
返回一个标识为重复的foos的主体.假设返回1,2,5(可能是名称).
然后你可以发出:
[DELETE]/foos,正文是一个包含1,2,5(或名称,如果唯一)的数组.删除调用是被动的,所以即使根据REST原则缓存GET调用也没关系.
通过http而不是REST路由(例如POX或JOSN RPC)也是有效的,但只是意识到它不是REST.这很好,但是你没有从fielding的论文中获得REST的好处.
http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm
另外,请阅读:
http://blog.steveklabnik.com/posts/2011-07-03-nobody-understands-rest-or-http
编辑:
在阅读了你澄清的评论之后,你发送服务器的是一组对象(不是持久的服务器端),并且它返回了带有dupes的子集(如服务器端辅助函数),一些选项是: