summaryrefslogtreecommitdiff
path: root/content
diff options
context:
space:
mode:
Diffstat (limited to 'content')
-rw-r--r--content/article/clj6.md8
1 files changed, 5 insertions, 3 deletions
diff --git a/content/article/clj6.md b/content/article/clj6.md
index 14d4bb3c..77698b71 100644
--- a/content/article/clj6.md
+++ b/content/article/clj6.md
@@ -16,7 +16,7 @@ endnotes = [
## 初识 Ring
-Ring 是对 Web 服务器的**低层**抽象,也就是说没有实现页面路由(router),和通常的后端框架(比如 Go 的 Gin、Python 的 Django、Java 的 Spring Web 等有很大区别。
+Ring 是对 Web 服务器的**低层**抽象,也就是说没有实现页面路由(router),和通常的后端框架(比如 Go 的 Gin、Python 的 Django、Java 的 Spring Web 等)有很大区别。
根据 [Ring Spec 1.6.1](https://github.com/ring-clojure/ring/blob/master/SPEC.md),Ring 主要有三个概念:
@@ -128,7 +128,7 @@ Handler 也应该返回一个映射,结构如下:
|`:headers`|`{String String}` or `{String [String]}` | Yes |
|`:status` |`Integer` | Yes |
-上述表格摘自 [Ring Spec](https://github.com/ring-clojure/ring/blob/master/SPEC.md)。大部分情况下我们都只需要使用 `:body` 和 `:headers`,也就是响应头(或请求头)以及响应体(或请求体),响应时还需要戴上 `:status`,即 HTTP 状态码。
+上述表格摘自 [Ring Spec](https://github.com/ring-clojure/ring/blob/master/SPEC.md)。大部分情况下我们都只需要使用 `:body` 和 `:headers`,也就是响应头(或请求头)以及响应体(或请求体),响应时还需要带上 `:status`,即 HTTP 状态码。
当然,如果你不用任何路由库,纯手动路由,那还要用到 `:request-method`(请求方法,如 `GET` `POST`)和 `:uri`(用来解析路径)。
@@ -152,7 +152,9 @@ Handler 做的事情其实就是对请求做些处理,然后构造响应。比
不过,访问 `/hello` 会得到 `Hello!`,但访问 `/hello/` 却是 `Not Found`。我们的路由匹配方式有缺陷。处理这些细节太麻烦了,有没有别的办法?
-## 路由器
+## Don't lose your composure
+
+[Compojure](https://github.com/weavejester/compojure) 是 Ring 的主要贡献者 [weavejester](https://github.com/weavejester) 维护的路由库。这个名字显然来自 *Composure*,意思是「沉着冷静」。其实还有更新更现代的 [reitit](https://github.com/metosin/reitit),不过我们还是先来看 Compojure 吧。
---