add servlet context path middleware

will be used by functions yet-to-be-added
This commit is contained in:
Gered 2014-03-22 16:57:21 -04:00
parent 84ee498aa2
commit 4cdf060750

View 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))))