Clojure noob here, I might be totally off the track or committing crimes, so please advise.
For ops, I have to often call rest services in different environments, say prod and nonprod. My coworkers use postman and clicky clicky stuff, well, not my style, I want to use emacs and cider. I've thus written a set of functions that call these services, taking the prod/nonprod server as an argument:
(ns services)
(defn rest [server arg1 arg2] ...)
I'm thinking how it would feel to get rid of the server parameter, and resolve it inside the function, depending on the current namespace. I can then just leave my cider open, use Cider shortcuts to switch to the prod/nonprod namespaces quickly and run my stuff. Also, I would be constantly aware of which environment I'm in by looking at the repl prompt. Sounds neat somehow. But I feel I am venturing off the track somehow, but this seems to work:
(ns prod
(:require
[services :refer :all]))
(ns nonprod
(:require
[services :refer :all]))
(ns services)
;; no more server arg...
(defn call-a [arg1 arg2]
(let [server @(resolve 'server)]
;; ... do stuff with server))
What do I miss? Complete nonsense? Better solutions?
Thanks again for comments,
Felix