Created
October 30, 2011 17:37
-
-
Save mefesto/1326168 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns myapp.middleware) | |
(defn wrap-content-type [handler content-type] | |
(fn [req] | |
(let [res (handler req)] | |
(if-not (contains? (:headers req) "Content-Type") | |
(assoc-in res [:headers "Content-Type"] content-type) | |
res)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns myapp.server | |
(:use [myapp.middleware :only (wrap-content-type)]) | |
(:require [noir.server :as server])) | |
(server/load-views "src/myapp/views/") | |
(defn -main [& m] | |
(let [mode (keyword (or (first m) :dev)) | |
port (Integer. (get (System/getenv) "PORT" "8080"))] | |
(server/add-middleware wrap-content-type "text/html") | |
(server/start port {:mode mode | |
:ns 'myapp}))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment