REST 客户端实施是否接受 HATEOAS 约束?
有谁知道 REST 客户端的实现包含 超媒体作为应用程序状态的引擎 (HATEOAS)?
从其记录方式来看,Sun Cloud API 似乎是一个不错的候选者,并且 < a href="http://blogs.oracle.com/craigmcc/entry/why_hateoas" rel="noreferrer">作者的声明,大意是 Ruby、Java 和 Python 实现正在开发中。 但到目前为止我还没有发现代码的踪迹。
我正在寻找任何东西 - 即使是部分实现也会有帮助。
Does anybody know of an implementation of a REST client that embraces the constraint of Hypermedia as the Engine of Application State (HATEOAS)?
The Sun Cloud API seems to be a good candidate, judging from the way it's documented and a statement by the author to the effect that Ruby, Java, and Python implementations were in the works. But so far I've found no trace of the code.
I'm looking for anything - even a partial implementation would be helpful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
Restfulie 是一个 Ruby、Java 和 C# 框架,旨在支持构建采用 HATEOAS 的客户端和服务器。 我没用过,但看起来确实很有趣。
这是来自他们的java项目的一些示例代码:
同样,我不确定这到底是做什么的,或者说它在实践中效果如何,但它看起来确实很有趣。
Restfulie is a Ruby, Java, and C# framework which aims to enable building clients and servers which employ HATEOAS. I haven't used it, but it does look interesting.
Here's some example code from their java project:
Again, I'm not sure exactly what this does, or how well it works in practice, but it does seem intriguing.
REST HTTP 和 HATEOAS 的问题在于,没有通用的方法来指定链接,因此很难跟踪链接,因为它们的结构可能会从一个服务提供商更改为另一个服务提供商。 有些会使用
其他人会使用链接的专有结构。
。 它不像 HTML 或 Atom 那样,链接是定义的标准的一部分。客户端无法知道您的表示中的链接是什么,因为它不知道您的媒体类型,除非存在链接的标准或常规表示
The problem with REST HTTP and HATEOAS is that there is no common approach to specifying links so it is hard to follow links since their structure might change from a service provider to another. Some would use
<link href="..." />
others would use proprietary structure for of links ex.<book href="..." />
. It is not like in HTML or atom were link are part of a standard defined.A client can't know what a link is in your representation is it doesn't know your media type unless there is a standard or conventional representation of a link
HATEOAS 设计原则(REST 也是一组设计原则)意味着每个资源最多应该有一个固定的 URL。
其他所有相关内容都应该可以通过“超媒体”链接从该 URL 动态发现。
我刚刚在此处创建了一个维基百科存根
The HATEOAS design principle (REST is a set of design principles also) means that each resource should have at most a single fixed URL.
Everything else related should be discoverable dynamically from that URL through "hypermedia" links.
I just started a wikipedia stub here
与此同时,还有 Spring HATEOAS 项目。 它还有一个客户端实现:
https://docs.spring.io/spring-hateoas /docs/current/reference/html/#client
In the meanwhile, there is the Spring HATEOAS project. It has also a client implementation:
https://docs.spring.io/spring-hateoas/docs/current/reference/html/#client
您应该首先查看的是常见的网络浏览器。 这是接受 HATEOAS(至少在某种程度上)的客户的标准。
这就是超媒体的工作原理。 它非常简单,几乎令人痛苦:
http://pigs-are-cool.org/
,现在简要说明这两个术语与 Web 浏览体验的关系:
因此,HATEOAS 实际上描述了当您从一个网页转到另一个网页时,网络浏览器中会发生什么:
HATEOAS 一词只是这种浏览体验的抽象。
RESTful 客户端应用程序的其他示例包括:
RESTful 客户端软件的一些特征:
),有些是手动的(如
)。
它们通常是由用户驱动的,可以正确地称为“用户代理”,但 GoogleBot 除外。
The very first thing you should look at is the common web browser. It is the standard for a client that embraces HATEOAS (at least to some degree).
This is how Hypermedia works. It's so simple that it's almost painful:
http://pigs-are-cool.org/
Now for a short explanation of how the two terms relate to the web browsing experience:
So HATEOAS actually describes what happens in a web browser when you go from web page to web page:
The term HATEOAS is just an abstraction of this browsing experience.
Other examples of RESTful client applications include:
Some characteristics of RESTful client software:
<img src=
) some manually (like<a href=
).Very often they are driven by a user, and can correctly be termed "user agents", except for, say GoogleBot.