diff options
author | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2012-06-25 21:00:19 +0200 |
---|---|---|
committer | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2012-06-25 21:00:19 +0200 |
commit | c341089a912e14e134a70edea2539406f090c824 (patch) | |
tree | 816f3a4ce490e783af57d6a2836a5ec1d0937da6 /src | |
parent | 06380786543fbe9c85f62ec2c4caa3e8fb6ff36d (diff) |
Minor code improvements.
Diffstat (limited to 'src')
-rw-r--r-- | src/mulk/benki/main.clj | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/mulk/benki/main.clj b/src/mulk/benki/main.clj index fec1c85..354358a 100644 --- a/src/mulk/benki/main.clj +++ b/src/mulk/benki/main.clj @@ -16,8 +16,7 @@ [aleph.formats :as aformats] [ring.util.codec :as codec] [clojure.algo.monads :as m] - [clojure.data.json :as json] - ) + [clojure.data.json :as json]) (:import [java.math BigDecimal BigInteger]) (:gen-class)) @@ -25,6 +24,9 @@ (defn wrap-missing-status-code [handler] (fn [request] (let [response (handler request)] + ;; NB. This is a work-around for aleph.http not accepting + ;; responses that do not contain a :status property. This + ;; includes `nil` responses. (assoc response :status (get response :status 404))))) (defn wrap-utf-8 [handler] @@ -112,6 +114,7 @@ response)))) (do-once ::init + (noir.server/add-middleware #(hiccup.middleware/wrap-base-url % (:base-uri @benki-config))) (noir.server/add-middleware #(wrap-missing-status-code %)) (noir.server/add-middleware #(wrap-utf-8 %)) (noir.server/add-middleware #(wrap-auth-token %)) @@ -122,7 +125,9 @@ (defn run-server [] (let [mode (or (:mode @benki-config) :production) - noir-handler (noir.server/gen-handler {:mode mode})] + noir-handler (noir.server/gen-handler {:mode mode, + :ns 'mulk.benki, + :base-url (:base-uri @benki-config)})] (ahttp/start-http-server (ahttp/wrap-ring-handler noir-handler) {:port (:web-port @benki-config) :websocket true}))) |