HATEOAS(REST 架构)的实际示例
每个人可能都已经注意到,有很多假的/基本的 REST-API(它们实现了 HTTP-API 并将其称为 REST,而不遵循超文本作为应用程序状态引擎的要求,这导致Roy T. Fielding 的著名咆哮 ,第一个指定 REST 范式的人)。
我一直无法找到任何真正超文本驱动的 REST 实现的实际示例以及状态转换的相关应用程序特定媒体类型定义。
是否有此类实现的公开示例?
as everyone may have noticed, there are lot of fake/rudimentary REST-APIs in the wild (which implement a HTTP-API and call it REST without following the hypertext-as-the-engine-of-application-state requirement, which led to the famous rant of Roy T. Fielding, the man who first specified the REST-paradigm).
I've been unable to find any practical examples of a truly hypertext driven REST-implementation along with the associated application-specific media-type definitions for the state transitions.
Are there any publicly accessible examples of such implementations?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
它不是运行代码意义上的实现,但我真的很喜欢这篇文章“How to GET一杯咖啡”在 InfoQ 上。 它将在星巴克点咖啡的过程描述为 RESTful 协议。 这超越了典型的“一切都是资源”的 REST 介绍性文章,重点关注 HATEOAS。 强烈推荐。
Its not an implementation in the sense of running code, but I really like the article "How to GET a cup of coffee" on InfoQ. It describes the process of ordering a coffee at Starbucks as a RESTful protocol. This goes beyond the typical "everything is a resource" REST introductory article and focuses on HATEOAS. Highly recommended.
Sun Cloud API? 从介绍来看:
背景故事也可能乐于助人。
How about the Sun Cloud API? From the introduction:
The backstory might also be helpful.
Netflix 有一个基于 HATEOAS 的 REST API,其中包含链接作为一部分的资源。
Netflix has a REST API based on HATEOAS that includes links as part of the resources.
Roy 的第四点实际上不是解决了 Sun Cloud API 的 RESTful 问题吗:
示例 1 已定义层次结构中的固定资源名称:
来自 Sun Cloud API:“...VDC 的表示将包括驻留在其中的集群的表示,而集群又包括 VM 的表示在每个簇内。”
示例2带外信息,例如特定领域的标准:
您必须拥有wiki页面内容(带外信息)才能知道“资源通信机制”对于云资源字段“uri”是 GET。
Isn't the RESTfulness of Sun Cloud API actually addressed in Roy's 4th point:
Example 1 Fixed resource names in a defined heirachy:
From the Sun Cloud API: "... the representation of a VDC will include representations of the Clusters which inhabit it, which in turn include representations of the VMs within each cluster."
Example 2 out-of-band information, such as a domain-specific standard:
You have to have the wiki-page contents (out-of-band information) to know that the "resource communication mechanism" for the Cloud resource field "uri" is GET.
我意识到不久前有人问过这个问题,但我尝试通过一个简单的示例来演示“正确的”REST API 流程。 我尝试遵循罗伊的休息规则 - 也许它会有所帮助:
使用 REST 的 API 示例
I realized this was asked a while ago, but I took a stab at demonstrating a "proper" REST API flow for a simple example. I tried to follow Roy's rules for REST - perhaps it could help:
API Example using REST