通用 REST 前端 - 它存在吗?
我正在寻找处理 HTTP 请求之上的一些薄层,可以根据 uri / 休息动词 / 实际服务位置 / ... 轻松路由到不同的后端。该层还应该将编码处理为任何请求的格式是(xml / json /返回二进制数据/等)。
但最重要的一点是使其可插入某些后端 - 无论是消息队列、作业调度程序、外部进程还是完全不同的东西。应使用最少的包装器来处理它们,以实现所需的消息翻译。
基本上,这将是一个可定制的请求调度程序,上面有一些魔法。现在有类似的东西作为单独的应用程序存在吗?
编辑:差点忘了 - 如果它是用 PHP 编写的那就太好了......但如果其他内容与描述相匹配,我也会看看。
I'm looking for some thin layer on top of handling HTTP requests that can easily do routing to different backends, based on the uri / rest verb / actual service location / .... This layer should also handle encoding into whatever the requested format is (xml / json / returning binary data / etc.).
The most important point though is to make it pluggable into some backend - whether it's a message queue, job dispatcher, external process, or something completely different. They should be handled with minimal wrapper for the needed message translation.
So basically, that would be a customisable request dispatcher with some magic on top. Does something like that exist as a separate application now?
Edit: Almost forgot - it would be great if it was written in PHP... but if something else matches the description, I'd have a look too.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不了解 PHP,但如果 Java 和/或 Python 是您可以接受的选项,您应该看看 RESTx< /a>,旨在简单快速地创建 RESTful 服务。 RESTx 是完全开源的,获得 GPLv3 许可。
我同意许多框架都是关于对象创建和映射的,这通常会非常烦人和妨碍。然而,RESTx 是关于数据、内容类型的自动转换等的。借助 RESTx,您可以使用 Java 或 Python 编写自定义组件。这些组件可以负责对数据库、自定义 API、遗留数据、云服务等的访问。RESTx 检查代码并自动生成自记录的、可发现的 RESTful API。这是您可以点击的所有链接。了解如何使用网络浏览器浏览服务器 。
关键是您可以将参数集发布到这些组件,然后在新的 URI 下存储和访问这些组件。您访问 URI,参数将应用于组件,然后您将获得输出。因此,您可以快速创建新的 RESTful Web 服务和资源。您可以从组件的代码中轻松访问其他资源,并且不会导致额外的 HTTP 请求。
我是 RESTx 的首席开发人员,因此如果您对此有任何疑问,请在论坛上与我联系(我们网站上的链接)。
Don't know about PHP, but if Java and/or Python are acceptable options for you, you should take a look at RESTx, which was designed for the simple and fast creation of RESTful services. RESTx is fully open source, GPLv3 licensed.
I agree that many frameworks are all about object creation and mapping, which often can be very annoying and get in the way. RESTx, however, is about the data, the automatic conversion of content types and so on. With RESTx you can write custom components in either Java or Python. These components can take care of access to databases, custom APIs, legacy data, cloud services, etc. RESTx examines the code and automatically produces a self documented, discoverable, RESTful API. It's all links you can follow. Take a look at how to take a tour of the server with a web browser.
The key is that you can POST parameter sets to those components which are then stored and accessible under a new URI. You access the URI, the parameters get applied to the component and you get the output back. Thus, you can rapidly create new RESTful web services and resources. You can access other resources easily from within your component's code and it doesn't cause an additional HTTP request.
I'm the lead developer for RESTx, so if you have any questions about it, please contact me on the forums (links to those are on our web site).
以 Mongrel 闻名的 Zed Shaw 正在尝试这样做。他正在创建 Mongrel2(仍在开发中),本质上是 Web 应用程序后端的通用前端。它允许您插入任何可以像反向代理一样发送和接收 0MQ 或 HTTP 消息的程序。
它还使用一个健全的配置文件系统:SQLite。不再用奇怪的语法搞乱 Apache 配置文件。
它是用 C 编写的,因此可能不像 PHP 这样的语言那么容易部署,但它的扩展性确实很好。
如果您对 Mongrel2 不满意,那么自行推出相对容易。我在自己的一个项目中使用了nodejitsu的node-http-proxy。它简单且快速。另外,您可以使用常规的旧
if
语句编写路由规则。我是 StackOverflow 的新手,所以它不允许我嵌入多个超链接,哈哈。
Zed Shaw of Mongrel fame is attempting to do just this. He's creating Mongrel2 (still in development), essentially a universal frontend for web application backends. It allows you to plug in any program that can send and receive 0MQ or HTTP messages like a reverse proxy.
It also uses a sane configuration file system: SQLite. No more messing around with Apache config files with weird syntax.
It's written in C, so it may not be as easy to deploy as a language like PHP, but it certainly scales very well.
If you're not satisfied with Mongrel2, it's relatively easy to roll your own. I've used nodejitsu's node-http-proxy for one of my own projects. It's simple and fast. Plus, you can write your routing rules using regular old
if
statements.I'm new to StackOverflow so it won't let me embed more than one hyperlink, haha.