下面是我的应用程序 -
(ns mfaiz.routes
(:use [net.cgrand.moustache :only [app]]
[net.cgrand.enlive-html :only [deftemplate content]]
[ring.util.response :only [response]]))
(deftemplate reg "mfaiz/templates/reg.html" [])
(def my-app (app
["hi"] "Hello World!"
["reg"] (-> ((-> "reg" symbol resolve)) response constantly)
[&] "Nothing was found"))
我在这条路线上遇到错误 -
["reg"] (-> ((-> "reg" symbol resolve)) response constantly)
如果我直接评估上述路由,它会正常工作并返回 html 文件 -
((-> "reg" symbol resolve))
如果我也更改路由以直接调用模板函数,那么它也可以工作 -
["reg"] (-> (reg) response constantly)
知道出了什么问题吗?
最佳答案
问题似乎在于,当它在环下运行时,“reg”未得到解析,因为它不完全合格。这取决于环服务器在哪个命名空间中启动。因此,使用完全限定名称即可:
(->“mfaiz.routes/reg”符号解析)
请检查解决
documentation 。它尝试解析当前命名空间中的符号,即 *ns*
关于clojure - 为什么环在这个响应中给我错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12313549/