remove wrap-base, just put the optional wrap-reload under http-server

i don't _really_ want to encourage the use of wrap-base as i think it
is usually the wrong place to add middleware to.

instead adding a placeholder :middleware list to the reitit ring-handler
as the intended alternative place for "global" middleware that needs to
be applied regardless of a reitit route match
This commit is contained in:
Gered 2022-01-05 18:34:18 -05:00
parent aa1aa76bbf
commit 473bed92df

View file

@ -131,15 +131,15 @@
coercion/coerce-request-middleware ; coercing request parameters
multipart/multipart-middleware ; multipart
]}})
(ring/routes
(ring/create-default-handler))))
(defn wrap-base
[handler]
(as-> handler h
(if (:dev? config) (wrap-reload h) h)
; TODO: other base middleware here
))
(ring/routes
(ring/create-default-handler))
; add any top-level middleware here that will be applied to the *entire* handler,
; regardless of the route matched, if any. (most of the time you'd want to use
; the :middleware list found above though...)
{:middleware []}))
;;
@ -168,7 +168,8 @@
:or {port 8080
bind "0.0.0.0"}} (:http-server config)
server (http-kit/run-server
(wrap-base #'handler)
(as-> #'handler h
(if (:dev? config) (wrap-reload h) h))
{:port port
:ip bind
:server-header nil