什么是我不理解关于REST? [英] What am I not understanding about REST?

查看:124
本文介绍了什么是我不理解关于REST?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立一个框架,并希望开发人员能够以允许与其他网站都共享数据,它的一部分,并允许其他网站添加/编辑/删除数据的能力。

I'm building a framework and want developers who build with it to have the ability to allow parts of it to both share data with other sites and allow other sites to add/edit/delete data.

例如,如果有人让有书评,作者,报价,code例子,评论等开发商可能使例如一个网站书评只读其他网站和评论由某些网站/用户的其他网站和可写可读。我们的想法是使用该框架构建可以容易地与其它应用程序互连应用

For example, if someone makes a site that has book reviews, authors, quotes, code examples, comments, etc. the developer could make e.g. "book reviews" read-only for other sites and "comments" readable by other sites and writable by certain sites/users. The idea is to use the framework to build applications that can easily be interconnected with other applications.

我设想能够与通过POST网站的所有交互和GET这将是这个样子:

I envision enabling all interaction with the site via POST and GET which would look something like this:


  • /books.php?category=ruby (返回约红宝石书籍XML集合)

  • /books.php?id=23 (返回XML某个具体的书)

  • /books.php?action=add&title=AdvancedRuby&description=....&securityId=923847203487

  • /books.php?action=delete&id=342&securityId=923847203487

  • /books.php?category=ruby (returns an XML collection of books about ruby)
  • /books.php?id=23 (returns the XML for a specific book)
  • /books.php?action=add&title=AdvancedRuby&description=....&securityId=923847203487
  • /books.php?action=delete&id=342&securityId=923847203487

其他应用也可以发现并使用什么是一定的网站有通过这样做是为了提供:

Other applications could also "discover and consume" what a certain site has to offer by doing this:


  • /discover.php (返回可用的所有公共类和动作的XML)

  • /discover.php (returns XML of all public classes and actions available)

这真的是我需要启用该框架为开发人员快速创建松散连接的站点的一种方式。

Really this is all I need to enable the framework to be a way for developers to quickly create loosely connected sites.

我想知道的是,在此之前我就开始实施这个,有没有REST的显著/有趣的部分,我还不知道我应该建设成框架,例如:


  • REST要求GET,POST,PUT和DELETE。为什么我会永远需要PUT和删除?我是否锁定自己离开采取一些标准的优势,如果我不使用这些?

  • 我的discover.php文件的功能类似于Web服务的WSDL文件。我在REST的描述惊讶似乎有游览服务,RESTful服务报价没有标准化的方式,或者是有?

  • 如果客户网站试图例如添加一本书到一个服务器的网站,并没有得到任何​​成功响应返回,它只会再试,直到它得到了响应。服务器网站将根本不添加同一本书的两倍。这是我在REST数据完整性的理解,有没有比这更给它?

  • 最后我想有具有同样丰富的类如多个站点书评,使客户的网站将能够执行code像这样的:

  • REST requires GET, POST, PUT and DELETE. Why would I ever need "PUT" and "DELETE"? Am I locking myself out from taking advantage of some standard if I dont' use these?
  • My "discover.php" file functions similarly to a WSDL file in web services. I am surprised in descriptions of REST there seems to be no standardized way of discovering the services that a RESTful service offers, or is there?
  • If a client website tries to e.g. add a book to a server website and does not get any "success" response back, it would simply try again until it got a response. The server website would simply not add the same book twice. This is my understanding of data integrity in REST, is there more to it than this?
  • eventually I want to have multiple sites that have the same rich classes e.g. "BookReview" so that a client site would be able to execute code such as this:

$书评=新书评(http://www.example.com/books.php?id=23);
$簿─> informAuthor(你的书的评论留言中被张贴在我们的网站......);

和服务器站点将发送一封电子邮件过这次审查的作者。
这类型的交互类型的REST风格理念的组成部分或REST仅仅是通过XML的数据交换,JSON?

and the server site would send an e-mail off to the author of that review. Is this type of type interaction a component of the RESTful philosophy or is REST simply the exchange of data via XML, JSON?

推荐答案

是我自己锁定了采取一些标准的优势,如果我不'用这些?

您是自己从HTTP标准锁定了。当然你也可以使用GET参数做同样的事情。它只是没有再休息,但一些RPC似的。

You are yourself locking out from the HTTP standard. Of course you can use GET parameters to do the same thing. It's just not REST then, but something RPC-Like.

我建议由Leonard Richardson和Sam Ruby的的书 REST Web服务?这是相当有趣的阅读和展示的不同方法之间的差异。

May I suggest the book RESTful Web Services by Leonard Richardson and Sam Ruby? It's quite fun to read and shows differences between the different approaches.

要回答更多的细节您的问题:这是由你来决定你走哪条路。从理论上讲,你可以做所有REST风格和RPC样的方法同样的东西。 REST风格的使用垫层HTTP协议是的的协议。随着RPC使用HTTP就像交通工具某处隐藏工作单中传输的数据。这导致(非必需)开销。

To answer your questions in a bit more detail: It's up to you to decide which way you go. In theory you can do all the same stuff with both RESTful and RPC-like approaches. With RESTful you use the underlaying HTTP protocol to be the protocol. With RPC you use HTTP just as a means of transportation and hide the work orders somewhere in the transported data. That leads to (unrequired) overhead.

只要看看两个你的例子:

Just look at two of your examples:


  • /books.php?action=add&title=AdvancedRuby&description=....&securityId=923847203487

  • /books.php?action=delete&id=342&securityId=923847203487

    • 有POST和PUT或DELETE,为何纷纷行动=添加和行动=删除?

    • 有HTTP认证。为什么要发明一个 - 可能不太安全? - securityId

    • BTW:你不应该允许通过GET数据更改。这只是一些不应该做的(另外一个话题,虽然;))

    这篇关于什么是我不理解关于REST?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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