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