Skip to content

Instantly share code, notes, and snippets.

Created December 26, 2012 22:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/4383596 to your computer and use it in GitHub Desktop.
Save anonymous/4383596 to your computer and use it in GitHub Desktop.
Dynamic scoping simulator for ring-handlers
(defmacro wrap-request-binding
"Encloses the ring handler definition in a function to simulate dynamic scope
on a request attribute via a lexical binding on the current request."
[binding-sym ks handler-def]
`(fn [req#]
(let [~binding-sym (get-in req# ~ks)]
(~handler-def req#))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment