基于REST的API运行时可发现/ HATEOAS客户端的设计 [英] RESTful API runtime discoverability / HATEOAS client design

查看:180
本文介绍了基于REST的API运行时可发现/ HATEOAS客户端的设计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关SaaS的启动我参与,我建立一个既RESTful网络API,并在消耗它不同的平台上一对夫妇的客户端应用程序。我想我已经得到了API想通了,但我现在转向客户端。正如我一直在阅读有关REST,我看到REST的一个关键部分是的发现的,但似乎有什么发现的真正含义两个不同的间pretations之间有很多争论:

For a SaaS startup I'm involved in, I am building both a RESTful web API and a couple of client apps on different platforms that consume it. I think I've got the API figured out, but now I'm turning to the clients. As I've been reading about REST, I see that a key part of REST is discovery, but there seems to be a lot of debate between two different interpretations of what discovery really means:


  1. 开发人员发现:开发人员硬codeS丰富大量的API的详细信息到客户端,如资源的URI,查询参数,支持HTTP方法,以及其他细节,他们'已经通过浏览文档和使用API​​的反应实验发现。这种类型的发现IMHO的就必须凉爽联动和API版本问题,并导致在客户端code键的API硬耦合。也好不到哪去比,如果使用RPC的似乎的证据充分的集合。

  1. Developer discovery: The developer hard-codes copious amounts of API details into the client, such as resource URI's, query parameters, supported HTTP methods, and other details that they've discovered through browsing the docs and experimenting with the API's responses. This type of discovery IMHO necessitates cool linkage and the API versioning question, and leads to hard coupling of the client code to the API. Not much better than if using a well-documented collection of RPC's it seems.

运行时发现 - 客户端应用程序本身能够计算出它与出带外很少或没有信息(presumably,只是媒体的知识所需要的一切类型的API交易。)链接可热。但是,为了使API非常有效的,对于查询参数很多链接模板似乎是必要的,这使得出带外方式悄悄回。还有其他可能的困难我都还没想到的,因为我没有得到在发展这一点。但我喜欢松散耦合的想法。

Runtime discovery - The client app itself is able to figure out everything it needs with little or no out-of-band information (presumably, only a knowledge of the media types the API deals with.) Links can be hot. But to make the API very efficient, a lot of link templating for query parameters seems to be needed, which makes out-of-band info creep back in. There are possibly other difficulties I haven't thought of yet since I haven't gotten to that point in development. But I do like the idea of loose coupling.

运行时发现似乎是REST的圣杯,但我看到precious有关如何实现这样的客户端小的讨论。几乎我发现所有的REST资源似乎认为开发者发现。任何人都知道的一些运行时发现的资源?最佳做法?实例或库与现实code?我在PHP(Zend框架)的一个客户端的工作。 Objective-C的(IOS)为其他。

Runtime discovery seems to be the holy grail of REST, but I'm seeing precious little discussion about how to implement such a client. Almost all REST sources I've found seem to assume Developer discovery. Anyone know of some Runtime discovery resources? Best practices? Examples or libraries with real code? I'm working in PHP (Zend Framework) for one client. Objective-C (iOS) for the other.

是运行时发现一个现实的目标,考虑到present一套工具和知识,在开发者社区?我可以写我的客户来对待所有的URI在一个不透明的方式,但如何做到这一点最有效是个问题,尤其是在低带宽连接。无论如何,URI的只是其中的一部分。怎么样在运行时上下文链接模板?如何从使得很多OPTIONS请求的通信支持哪些方法,一边?

Is Runtime discovery a realistic goal, given the present set of tools and knowledge in the developer community? I can write my client to treat all of the URI's in an opaque manner, but how to do this most efficiently is a question, especially over low-bandwidth connections. Anyway, URI's are only part of the equation. What about link templating in the Runtime context? How about communicating what methods are supported, aside from making a lot of OPTIONS requests?

推荐答案

在这个视频乔恩·摩尔构建使用运行时HATEOAS自动发现一个通用的客户端。这是pretty IM pressive,非常值得关注:

In this video Jon Moore builds a generic client using runtime HATEOAS auto discovery. It is pretty impressive and well worth watching:

http://oredev.org/oredev2010/2010/sessions/hypermedia- apis.html

这篇关于基于REST的API运行时可发现/ HATEOAS客户端的设计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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