Last active
August 29, 2015 14:03
-
-
Save kolov/84cafcb5557fb6cd59bb to your computer and use it in GitHub Desktop.
Ring middleware to bind request and response to variables easy to explore in the repl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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)) | |
resp)) | |
(handler req) | |
))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example usage:
Then, after a call to /service/xxx, in the namespace of the bind-req-resp: