Drop compojure dependency
It was hardly used and makes control flow, reloaded workflow more difficult.
This commit is contained in:
parent
58373496f0
commit
ec27d58e31
2 changed files with 23 additions and 21 deletions
|
@ -8,7 +8,6 @@
|
|||
[org.clojure/core.async "0.1.346.0-17112a-alpha"]
|
||||
[om "0.7.3"]
|
||||
[http-kit "2.1.18"]
|
||||
[compojure "1.1.8"]
|
||||
[ring/ring-core "1.3.0" :exclusions [org.clojure/tools.reader]]
|
||||
[ring/ring-devel "1.3.0" :exclusions [org.clojure/tools.reader]]
|
||||
[hiccup "1.0.5"]
|
||||
|
|
|
@ -4,10 +4,8 @@
|
|||
[grub.test.integration.core :as integration-test]
|
||||
[grub.state :as state]
|
||||
[ring.middleware.file :as file]
|
||||
[ring.middleware.content-type :as content-type]
|
||||
[ring.util.response :as resp]
|
||||
[compojure.core :refer [defroutes GET POST]]
|
||||
[compojure.handler :as handler]
|
||||
[compojure.route :as route]
|
||||
[org.httpkit.server :as httpkit]
|
||||
[clojure.core.async :as a :refer [<! >! chan go]]
|
||||
[hiccup
|
||||
|
@ -42,26 +40,31 @@
|
|||
|
||||
(def index-page (atom dev-index-page))
|
||||
|
||||
(defn websocket-handler [request]
|
||||
(when (:websocket? request)
|
||||
(def default-port 3000)
|
||||
|
||||
(defn handle-websocket [handler]
|
||||
(fn [{:keys [websocket?] :as request}]
|
||||
(if websocket?
|
||||
(httpkit/with-channel request ws-channel
|
||||
(let [to-client (chan)
|
||||
from-client (chan)]
|
||||
(ws/add-connected-client! ws-channel to-client from-client)
|
||||
(state/sync-new-client! to-client from-client)))))
|
||||
(state/sync-new-client! to-client from-client)))
|
||||
(handler request))))
|
||||
|
||||
(defroutes routes
|
||||
(GET "/" [] websocket-handler)
|
||||
(GET "/" [] @index-page)
|
||||
(GET "*/src/cljs/grub/:file" [file] (resp/file-response file {:root "src/cljs/grub"}))
|
||||
(GET "/js/public/js/:file" [file] (resp/redirect (str "/js/" file)))
|
||||
(route/files "/")
|
||||
(route/not-found "<p>Page not found.</p>"))
|
||||
|
||||
(def default-port 3000)
|
||||
(defn handle-root [handler]
|
||||
(fn [{:keys [uri] :as request}]
|
||||
(if (= uri "/")
|
||||
(resp/response @index-page)
|
||||
(handler request))))
|
||||
|
||||
(defn start-server [port]
|
||||
(httpkit/run-server (handler/site routes) {:port port}))
|
||||
(httpkit/run-server (-> (fn [req] "Not found")
|
||||
(file/wrap-file "public")
|
||||
(content-type/wrap-content-type)
|
||||
(handle-root)
|
||||
(handle-websocket))
|
||||
{:port port}))
|
||||
|
||||
(defn run-integration-test []
|
||||
(let [stop-server (start-server integration-test/server-port)]
|
||||
|
|
Loading…
Reference in a new issue