0

使用引导运行时,我无法从 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)))
4

1 回答 1

0

您可以使用boot-http和类似以下内容:

 (boot (serve :handler 'server/-main :reload true) (wait))
于 2016-10-17T05:37:14.683 回答