The answer that worked for me and seems most idiomatic is to put the above connection into a function init
in that same file (myproject/handler.clj
)
(defn init[] (mg/connect-via-uri! (System/getenv "MONGOLAB_URI")))
and update the project.clj
file ring descriptor line from
:ring {:handler myproject.handler/app}
to
:ring {:handler myproject.handler/app :init myproject.handler/init}