Squeak/Pharo Web 服务的微框架
许多语言都有用于编写非常小的网站或 Web 服务的微框架,例如用于 Python 的 Flask 或用于 Ruby 的 Sinatra。在 Squeak 上,似乎没有任何类似的东西; 《伊利亚特》、《海边》和《AIDA》都非常重,只是提供了一点服务。实现此目的的首选方法是什么?直接将handler注入Comanche或Swazoo?
Lots of languages have microframeworks for writing very tiny websites or web services, such as Flask for Python, or Sinatra for Ruby. On Squeak, there doesn't seem to be any equivalent; Iliad, Seaside, and AIDA are all very heavy for just having a little service. What's the preferred way to accomplish this? Directly injecting a hanlder into Comanche or Swazoo?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
对于非常简单的情况,您可以像这样注册(或子类)Kom 的 HttpService(从类注释中,请参阅 参考资料 获取更多信息/选项):
For really simple cases, you can just register with (or subclass) Kom's HttpService like so (from the class comment, see for more info/options):
您还可以使用茶壶。 Teapot 是基于 Zinc HTTP 组件之上的微型 Web 框架,专注于简单性和易用性。不包括测试,代码不到 500 行。
在过滤器之前有可用的胡子模板、输出变压器。该框架有详细记录。
You can also use teapot. Teapot is micro web framework on top of the Zinc HTTP components, that focuses on simplicity and ease of use. It's under 500 lines of code, not counting the tests.
There are available mustache templates, output transformers, before filters. The framework is well documented.
我想分享我认为更最新的信息(截至 2012 年底)。
锌组件
目前在 Pharo 1.4/2.0 中,HTTP 客户端/服务器的事实标准似乎是 锌 HTTP 组件。最新的 Seaside 版本(3.0)也切换到了 Zinc。
当然,您可以直接使用 Zinc 来实现 Web 服务或提供网页服务。
特别查看
ZnServer
类并搜索Zn*Delegate
等类(如ZnDefaultServerDelegate
或ZnStaticFileServerDelegate
) REST
Seaside 的最新版本包括对 RESTful Web 服务的支持。这可用于实现网络服务或提供网页。这非常简单。
有关详细信息,请参阅在线 Seaside 书籍的“REST 服务”一章。本章的重点是实现 Web 服务,但它也适用于网页。
Ratpack
我还听说过 Ratpack,这是一个由 Tim Felgentreff 开发的类似 sinatra 的网络框架。有两个存储库。我认为 github 是更新的。请参阅此处:
此信息来自 类似问题我最近发布了。
I would like to share what I think is more up-to-date information (as of end of 2012).
Zinc Components
Currently in Pharo 1.4/2.0 the de-facto standard for HTTP client/server seems to be the Zinc HTTP Components. And the latest Seaside version (3.0) switched to Zinc as well.
You can of course use Zinc directly to implement web-services or serve web-pages.
Take a look particularly at classes
ZnServer
and search for classes likeZn*Delegate
(likeZnDefaultServerDelegate
orZnStaticFileServerDelegate
)Seaside REST
Latest versions of Seaside include support for RESTful web-services. This can be used to implement web-services or serve web-pages. It's pretty straightforward.
For more information look at the "REST Services" chapter of the online Seaside book. This chapter centers about implementing web-services, but it works for web-pages as well.
Ratpack
I have also been told about Ratpack, a sinatra-like web-framework developed by Tim Felgentreff. There are two repositories. I think the github one is more recent. See here:
This information comes from a similar question I posted recently.
您可以在 Swazoo 中为这样一个微型网站子类化 SwazooSite,但我认为您很快就会不再需要更多功能,因此从长远来看,直接从这三个框架之一开始是更好的选择。
它们很重可能只是一种印象,并且缺乏更好的此类简单网站的使用文档。另外,如果您将框架视为黑盒,其内部复杂但外部简单,那么我会说与其他 Web 框架相比,所有 Smalltalk Web 框架都非常简单。
You can subclass a SwazooSite in Swazoo for such a micro website, but I think you will soon end needing more functionality, so starting directly on one of those three frameworks are better bet long-term.
That they are heavy is maybe just an impression and lack of better documentation of usage for such simple websites. Also, if you look at the framework as blackbox, which is complex internally but simple externally, then I'd say all Smalltalk web frameworks are quite simple comparing to other web frameworks.