当使用boot运行时,我无法从http-kit服务器获得任何响应。它适用于防波堤。当我运行boot run
时,它在一段时间后退出。所以我添加了(boot (wait))
,它不会终止,但服务器似乎没有运行。
; core.clj
(ns server.core
(:use [compojure.route :only [files not-found]]
[compojure.handler :only [site]]
[compojure.core :only [defroutes GET POST DELETE ANY context]]
org.httpkit.server))
(defn hello []
"Hello from httpkit")
(defroutes api-routes
(GET "/" [] (hello)))
(defn -main []
(run-server api-routes {:port 8080}))
boot.clj
文件:
;boot.clj
(set-env!
:source-paths #{"src"}
:dependencies '[[org.clojure/clojure "1.8.0"]
[ring "1.5.0"]
[compojure "1.5.1"]
[http-kit "2.2.0"]])
(require '[server.core :as server])
(deftask run []
(with-pre-wrap fileset (server/-main) fileset)
(boot (wait)))
您可以使用boot-http和以下内容:
(boot (serve :handler 'server/-main :reload true) (wait))