From 2504037a4b4e0db1eea0455dbe95f299a7784a8d Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Wed, 22 Feb 2012 11:54:02 +0100 Subject: Make mulk.benki.config/benki-config an atom. --- src/mulk/benki/config.clj | 2 +- src/mulk/benki/db.clj | 6 +++--- src/mulk/benki/main.clj | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/mulk/benki/config.clj b/src/mulk/benki/config.clj index 4b9493b..cd3c8b7 100644 --- a/src/mulk/benki/config.clj +++ b/src/mulk/benki/config.clj @@ -2,4 +2,4 @@ (:refer-clojure)) (def benki-config - (read-string (slurp "config.sexp"))) + (atom (read-string (slurp "config.sexp")))) diff --git a/src/mulk/benki/db.clj b/src/mulk/benki/db.clj index 61de478..343b09f 100644 --- a/src/mulk/benki/db.clj +++ b/src/mulk/benki/db.clj @@ -4,11 +4,11 @@ (:require [clojure.java.jdbc :as sql])) -(def ^:private db - (:database benki-config)) +(defn ^:private db [] + (:database @benki-config)) (defn call-with-db [thunk] - (sql/with-connection db + (sql/with-connection (db) (thunk))) (defmacro with-db [& body] diff --git a/src/mulk/benki/main.clj b/src/mulk/benki/main.clj index 2f4101f..09def98 100644 --- a/src/mulk/benki/main.clj +++ b/src/mulk/benki/main.clj @@ -22,7 +22,7 @@ (defn wrap-base-uri [handler] (fn [request] - (let [base-uri (:base-uri benki-config)] + (let [base-uri (:base-uri @benki-config)] (hiccup.core/with-base-url base-uri ((noir.options/wrap-options handler {:base-url base-uri}) request))))) @@ -31,7 +31,7 @@ (noir.server/add-middleware #(wrap-base-uri %)) (noir.server/add-middleware #(ring.middleware.file/wrap-file % "static"))) -(defonce server (doto (Thread. #(noir.server/start (:web-port benki-config))) +(defonce server (doto (Thread. #(noir.server/start (:web-port @benki-config))) (.setDaemon true) (.start))) -- cgit v1.2.3