tweaks to how the app ring-handler is set up
This commit is contained in:
parent
5e979c8ba5
commit
0debaadd90
|
@ -19,7 +19,7 @@
|
||||||
:main main
|
:main main
|
||||||
:plugins [[lein-ring "0.8.10"]
|
:plugins [[lein-ring "0.8.10"]
|
||||||
[lein-environ "0.4.0"]]
|
[lein-environ "0.4.0"]]
|
||||||
:ring {:handler toascii.handler/app
|
:ring {:handler toascii.handler/handle-app
|
||||||
:init toascii.handler/init
|
:init toascii.handler/init
|
||||||
:destroy toascii.handler/destroy}
|
:destroy toascii.handler/destroy}
|
||||||
:profiles {:uberjar {:aot :all}
|
:profiles {:uberjar {:aot :all}
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
(:require [ring.middleware.file :refer [wrap-file]]
|
(:require [ring.middleware.file :refer [wrap-file]]
|
||||||
[ring.middleware.file-info :refer [wrap-file-info]]
|
[ring.middleware.file-info :refer [wrap-file-info]]
|
||||||
[ring.server.standalone :refer [serve]]
|
[ring.server.standalone :refer [serve]]
|
||||||
[toascii.handler :refer [app init destroy]])
|
[toascii.handler :refer [handle-app init destroy]])
|
||||||
(:gen-class))
|
(:gen-class))
|
||||||
|
|
||||||
(defonce server (atom nil))
|
(defonce server (atom nil))
|
||||||
|
|
||||||
(defn get-handler []
|
(defn get-handler []
|
||||||
(-> #'app
|
(-> #'handle-app
|
||||||
(wrap-file "resources")
|
(wrap-file "resources")
|
||||||
(wrap-file-info)))
|
(wrap-file-info)))
|
||||||
|
|
||||||
|
|
|
@ -15,20 +15,24 @@
|
||||||
(route/resources "/")
|
(route/resources "/")
|
||||||
(route/not-found "Not Found"))
|
(route/not-found "Not Found"))
|
||||||
|
|
||||||
(defonce routes (find-routes "toascii.routes." app-routes))
|
(defonce ring-app (atom nil))
|
||||||
|
|
||||||
(def app (app-handler
|
(defn handle-app [request]
|
||||||
routes
|
(@ring-app request))
|
||||||
:middleware [wrap-exceptions wrap-servlet-context-path]
|
|
||||||
:access-rules []
|
|
||||||
:formats [:json-kw :edn]))
|
|
||||||
|
|
||||||
(defn init []
|
(defn init []
|
||||||
(set-config! [:shared-appender-config :spit-filename] "toascii.log")
|
(set-config! [:shared-appender-config :spit-filename] "toascii.log")
|
||||||
(set-config! [:appenders :spit :enabled?] true)
|
(set-config! [:appenders :spit :enabled?] true)
|
||||||
(set-config! [:fmt-output-fn] log-formatter)
|
(set-config! [:fmt-output-fn] log-formatter)
|
||||||
|
|
||||||
(log :info "toascii started successfully")
|
(log :info "Starting up ...")
|
||||||
|
|
||||||
|
(reset! ring-app
|
||||||
|
(app-handler
|
||||||
|
(find-routes "toascii.routes." app-routes)
|
||||||
|
:middleware [wrap-exceptions wrap-servlet-context-path]
|
||||||
|
:access-rules []
|
||||||
|
:formats [:json-kw :edn]))
|
||||||
|
|
||||||
(when (env :dev)
|
(when (env :dev)
|
||||||
(log :info "Dev environment. Template caching disabled.")
|
(log :info "Dev environment. Template caching disabled.")
|
||||||
|
@ -36,8 +40,5 @@
|
||||||
|
|
||||||
(flf/load-all!))
|
(flf/load-all!))
|
||||||
|
|
||||||
(defn destroy
|
(defn destroy []
|
||||||
"destroy will be called when your application
|
(log :info "Shutting down ..."))
|
||||||
shuts down, put any clean up code here"
|
|
||||||
[]
|
|
||||||
(log :info "toascii is shutting down..."))
|
|
||||||
|
|
Reference in a new issue