成熟Clojure web框架? [英] Mature Clojure web frameworks?

查看:180
本文介绍了成熟Clojure web框架?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

成熟的Clojure Web框架目前的选择是什么?我正在寻找某种功能矩阵告诉我流行框架支持什么程度,包括:

What are the current choices of mature Clojure web frameworks? I am looking for some kind of feature matrix telling me what the popular frameworks support and to what extent, including:


  • 响应模板在Clojure或其他标记中 - 例如JSP with Tiles)

  • HTTP会话

  • REST会自动将URL映射到操作函数和参数

  • HTML表单(可用作地图,错误处理和验证的参数)

  • 应用程序流(从Java框架知道 - 请求处理程序返回操作标识符,最终由渲染器处理)

  • Response templating (response written in Clojure or in some other markup - e.g. like JSP with Tiles)
  • HTTP sessions
  • REST with automatic mapping of URLs into action-functions and params
  • HTML forms (params available as map, error handling, validation)
  • Application flow (known from Java frameworks - request handlers return action identifiers which are eventually handled by renderers)

推荐答案

也许我的回答在Clojure中开发RESTful Web服务的好起点?对SO的问题可能对您有帮助。它提到了一些重要的Web图书馆Clojure(链接和简短摘要)。我在这里重申的要点在该答案的第一段说明:

Perhaps my answer to the What is the good starting point to developing RESTful web service in Clojure? question on SO might be of help to you. It mentions some important web libraries for Clojure (with links and short summaries). The key point which I would like to reiterate here is stated in the first paragraph of that answer:


首先,我认为你不可能找到一个单一的收缩包装解决方案在Clojure做所有这一切(除了以Java库的形式通过互操作使用)。什么是成为Clojure的标准Web堆栈包括许多图书馆,人们以各种方式组合和匹配(因为他们高兴地倾向于完全兼容)。

First of all, I think that you are unlikely to find a single shrinkwrapped solution to do all this in Clojure (except in the form of a Java library to be used through interop). What is becoming Clojure's standard Web stack comprises a number of libraries which people mix and match in all sorts of ways (since they happily tend to be perfectly compatible).

我要补充一点,你可能不应该期望处理类似于应用程序流你可能从Java知道的东西(或者如果你相信你真的需要它,你可能需要滚动你自己的lib来支持它!)。这很好,因为人们似乎对Ring的处理程序是一种功能,高级 - 中间件友好的方法非常满意。

To that I would add that you should probably not expect to handle things with the sort of "application flow" you might know from Java (or if you believe you really need it, you'll probably have to roll your own lib to support it!). That's alright, though, as people seem to be very happy with Ring's handler-is-a-function, higher-order-middleware-friendly approach.

要处理您的项目符号:


  • 响应模板:

    Clojure特定解决方案的数量,包括 Enlive Hiccup (Enlive是一个非常强大的HTML抓取/模板/转换引擎; Hiccup是一个DSL,用于在Clojure中编写HTML,快速)。此外,这可能是一个地方,下降到Java和使用类似的东西,如说, StringTemplate 。这甚至有不鼓励模板和逻辑混合的好方面! (我相信Stuart Halloway曾经提到,相关性 - 他的公司正在使用这个策略,并取得巨大成功。)

  • Response templating:
    There is a number of Clojure-specific solutions, including Enlive and Hiccup (Enlive is a very powerful HTML scraping / templating / transforming engine; Hiccup is a DSL for writing HTML in Clojure with the nice property that it renders fast). Also, this is probably one place where it makes perfect sense to drop down to Java and use something like, say, StringTemplate. This even has the good side of discouraging the mixing of templates and logic! (I believe Stuart Halloway has mentioned that Relevance -- his company -- is using this strategy in their work and having great success with it.)

HTTP会话

我想是 Sandbar 。作者已启动一系列博客

HTTP sessions
That would be Sandbar, I suppose. The author has started a series of blogposts about it which looks very promising.

REST会自动将URL映射到操作函数和参数

这是 Ring & Compojure 和/或小胡子

REST with automatic mapping of URLs into action-functions and params
That's Ring & Compojure and/or Moustache. See below.

HTML表单(可用作地图,错误处理和验证的参数)

如上所述。

HTML forms (params available as map, error handling, validation)
As above.

应用程序流程(从Java框架知道 - 请求处理程序返回最终由渲染器处理的操作标识符)

如上所述,人们往往不会在Clojure中。

Application flow (known from Java frameworks - request handlers return action identifiers which are eventually handled by renderers)
As mentioned above, not really something people tend to do in Clojure.

网络堆栈, this Ring tutorial by Ring 的作者Mark McGranaghan是非常有帮助的。 Compojure 的作者James Reeves拥有一些文档。也许我最近的回答什么是compojure路线后面的大想法?问题可能也有帮助。 Ring的来源还包括一个伟大的SPEC文档。

As a starting point in learning about the Clojure web stack, this Ring tutorial by Ring's author Mark McGranaghan is very helpful. Compojure's author James Reeves has some documentation on Compojure. Perhaps my recent answer to the What’s the "big idea" behind compojure routes? question might be of help too. Ring's sources also include a great SPEC document.

这篇关于成熟Clojure web框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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