Squeak/Pharo Web 服务的微框架

发布于 2024-10-09 00:06:54 字数 174 浏览 0 评论 0原文

许多语言都有用于编写非常小的网站或 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

哥,最终变帅啦 2024-10-16 00:06:54

“在这种特殊情况下,我实际上有三个 URL 需要通过 HTTP POST 执行操作;仅此而已。”

对于非常简单的情况,您可以像这样注册(或子类)Kom 的 HttpService(从类注释中,请参阅 参考资料 获取更多信息/选项):

    (HttpService on: 8080 named: 'Example Http Service')
    onRequestDo: [ :httpRequest | SomeGlobal processRequest: httpRequest ];
    start

"In this particular case, I literally have three URLs that need to do stuff via HTTP POST; that's it."

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):

    (HttpService on: 8080 named: 'Example Http Service')
    onRequestDo: [ :httpRequest | SomeGlobal processRequest: httpRequest ];
    start
空心空情空意 2024-10-16 00:06:54

您还可以使用茶壶。 Teapot 是基于 Zinc HTTP 组件之上的微型 Web 框架,专注于简单性和易用性。不包括测试,代码不到 500 行。

Teapot on
    GET: '/hi' -> 'Bonjour!';
    GET: '/hi/<user>' -> [:req | 'Hello ', (req at: #user)];
    GET: '/say/hi/*' -> (Send message: #greet: to: greeter);
    start.

(ZnEasy get: 'http://localhost:1701/hi/user1') entity string. "Hello user1"

在过滤器之前有可用的胡子模板、输出变压器。该框架有详细记录。

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.

Teapot on
    GET: '/hi' -> 'Bonjour!';
    GET: '/hi/<user>' -> [:req | 'Hello ', (req at: #user)];
    GET: '/say/hi/*' -> (Send message: #greet: to: greeter);
    start.

(ZnEasy get: 'http://localhost:1701/hi/user1') entity string. "Hello user1"

There are available mustache templates, output transformers, before filters. The framework is well documented.

浅听莫相离 2024-10-16 00:06:54

我想分享我认为更最新的信息(截至 2012 年底)。

锌组件

目前在 Pharo 1.4/2.0 中,HTTP 客户端/服务器的事实标准似乎是 锌 HTTP 组件。最新的 Seaside 版本(3.0)也切换到了 Zinc。

当然,您可以直接使用 Zinc 来实现 Web 服务或提供网页服务。

特别查看 ZnServer 类并搜索 Zn*Delegate 等类(如 ZnDefaultServerDelegateZnStaticFileServerDelegate

) 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 like Zn*Delegate (like ZnDefaultServerDelegate or ZnStaticFileServerDelegate)

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.

柠北森屋 2024-10-16 00:06:54

您可以在 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文