I have Clojure code which makes HTTP requests to a server. Depending
on the context, I want to swap out the underlying HTTP library code.
For example, I use an instrumented library in a testing context and a
different library in a REPL context where the instrumented library
will not work. These are low-lying functions - the http/get and http/
put - called within other functions for doing specific kinds of
requests which are called in turn by other functions.

What I'm wondering is what are good ways to dynamically choose which
versions of those low-lying functions to use?

For now, I'm doing this within the namespace that uses the low-lying
functions..

(def get (if (context-flag?) ns.one.http-instrumented/get ns.two.http-
repl/get))

What I don't like about this is that context-flag feeling like a hacky
approach.

Thoughts?

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to