add servlet context path middleware
will be used by functions yet-to-be-added
This commit is contained in:
parent
84ee498aa2
commit
4cdf060750
12
src/clj_jtwig/web/middleware.clj
Normal file
12
src/clj_jtwig/web/middleware.clj
Normal file
|
@ -0,0 +1,12 @@
|
|||
(ns clj-jtwig.web.middleware)
|
||||
|
||||
(declare ^:dynamic *servlet-context-path*)
|
||||
|
||||
(defn wrap-servlet-context-path
|
||||
"Binds the current request's context path to a var which we can use in
|
||||
various jtwig functions that need it without having to explicitly
|
||||
pass the path in as a function parameter."
|
||||
[handler]
|
||||
(fn [req]
|
||||
(binding [*servlet-context-path* (:context req)]
|
||||
(handler req))))
|
Reference in a new issue