我试图运行阿列弗在环的顶部,并使用lein ring server作为较短的反馈回路。
当我调用lein ring server时,一切似乎都很好,但是当我将浏览器指向url时,我会得到一个带有下面堆栈跟踪的讨厌的NullPointerException。
但是,当我运行(al.app/start 3006)时,没有出现NLP。
整个项目可在GitHub上使用。
我做错了什么?
core.clj:107 lamina.core/enqueue
app.clj:39 al.app/hello-handler
http.clj:79 aleph.http/wrap-aleph-handler[fn]
response.clj:27 compojure.response/eval1328[fn]
response.clj:10 compojure.response/eval1289[fn]
core.clj:93 compojure.core/make-route[fn]
core.clj:39 compojure.core/if-route[fn]
... 我正在使用aleph 0.3.2,这是我的代码:
(ns al.app
(:use
aleph.http
lamina.core
compojure.core
ring.middleware.keyword-params)
(:require [compojure.route :as route]))
(defn hello-handler
"Our handler for the /hello path"
[ch request]
(let [params (:route-params request)
name (params :name)]
(enqueue ch
{:status 200
:headers {}
:body (str "Hello " name)})))
(defroutes my-routes
(GET ["/hello/:name", :name #"[a-zA-Z]+"] {} (wrap-aleph-handler hello-handler))
(route/not-found "Page not found"))
(defn start
"Start our server in the specified port"
[port]
(start-http-server (wrap-ring-handler my-routes) {:port port})) 发布于 2014-06-19 13:06:13
Lein插件使用嵌入式Jetty web服务器,而Aleph使用异步Netty web服务器。aleph.http/wrap-aleph-handler中间件的设计仅适用于使用aleph.http/start-http-server函数启动的Netty服务器。
https://stackoverflow.com/questions/24278946
复制相似问题