config file (for ring in particular)?

Skip to first unread message

Dick Davies

Jan 22, 2013, 5:05:25 AM1/22/13
Bit of a noob but have managed to get a well - performing rest service
(plain ring and a bit of c3p0 + jdbc) put together.

Idea is to deploy as an uberjar and then configure it via a config file


daemonize java -jar my-rest-thing.jar config.clj

The -main in my app passes the file to a utility function like this:

(defn -main
(let [cfg (utils/load-config configfile)]
(run-jetty handler {:port (cfg :http-port)}))))

Which is fine to configure jetty, but I'm not sure how to 'export' the
'cfg' map
to other functions - jdbc in particular - in the handler.

Would you generally wrap the first arg to run-jetty (with partial or similar),
or set an atom ? I'm guessing the latter, but haven't found any idiomatic code
samples yet.


Dick Davies

Jan 29, 2013, 9:45:38 AM1/29/13
to Feng Shen,
Thanks, did something very similar in the end.
Seemed a bit odd to use an atom when I'm never going
to change the contents, but works quite nicely.

On 29 January 2013 14:37, Feng Shen <> wrote:
> I do something like these for my code:
> (defonce configs (atom {}))
> (swap! configs merge cfg)
Reply all
Reply to author
0 new messages