Skip to content

Instantly share code, notes, and snippets.

@kolov
kolov / bind-req-resp.clj
Last active August 29, 2015 14:03
Ring middleware to bind request and response to variables easy to explore in the repl
(declare dbg-req)
(declare dbg-resp)
(defn bind-req-resp [handler re-pattern]
(fn [req]
(if (re-matches re-pattern (:uri req))
(do
(alter-var-root (var dbg-req) (constantly req))
(let [resp (handler req)]
(alter-var-root (var dbg-resp) (constantly resp))