我正在尝试理解clojure liberator,我遇到了下面这种类型的代码:
:handle-ok (by-method {
:get (fn [ctx] (render-item (:item ctx)))
:post (fn [ctx] (render-item (:item ctx)))
:put (fn [ctx] (update-item-response coll-slug ctx))})起初,我认为handle-ok只是用于GET请求,但后来我发现了这一点。
为什么我要在上面的例子中为post和put提供处理程序?就是这些请求后处理程序。
发布于 2014-05-22 18:10:28
看看底部的decision graph,在那里您可以看到结果代码200。将鼠标悬停在它上面会告诉你,这实际上就是:handle-ok发挥作用的地方。200的状态码可以是通过决策图的许多不同路径的结果,包括put和post。
https://stackoverflow.com/questions/23723071
复制相似问题