From c341089a912e14e134a70edea2539406f090c824 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Mon, 25 Jun 2012 21:00:19 +0200 Subject: Minor code improvements. --- src/mulk/benki/main.clj | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src') 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}))) -- cgit v1.2.3