explicitly set content-type header for 401, 404 and 500 error pages

Apparently the local Jetty instance is a bit more forgiving of this ..?
This commit is contained in:
Gered 2013-06-07 20:38:16 -04:00
parent fae0940f3a
commit e0388eccca
2 changed files with 9 additions and 6 deletions

View file

@ -19,8 +19,9 @@
(route/resources "/") (route/resources "/")
(wrap-head (wrap-head
(fn [request] (fn [request]
(->> (layout/render "notfound.html") {:status 404
(resp/status 404))))) :headers {"Content-Type" "text/html"}
:body (layout/render "notfound.html")})))
(defn init (defn init
"init will be called once when "init will be called once when
@ -57,8 +58,9 @@
(app request) (app request)
(catch Exception e (catch Exception e
(.printStackTrace e) (.printStackTrace e)
(->> (layout/render "error.html" {:error-info e}) {:status 500
(resp/status 500)))))) :headers {"Content-Type" "text/html"}
:body (layout/render "error.html" {:error-info e})}))))
;;append your application routes to the all-routes vector ;;append your application routes to the all-routes vector
(def all-routes [auth-routes home-routes posts-routes files-routes rss-routes]) (def all-routes [auth-routes home-routes posts-routes files-routes rss-routes])

View file

@ -31,8 +31,9 @@
(resp/redirect "/")) (resp/redirect "/"))
(defn handle-unauthorized [] (defn handle-unauthorized []
(->> (layout/render "unauthorized.html") {:status 401
(resp/status 401))) :headers {"Content-Type" "text/html"}
:body (layout/render "unauthorized.html")})
(defroutes auth-routes (defroutes auth-routes
(GET "/unauthorized" [] (handle-unauthorized)) (GET "/unauthorized" [] (handle-unauthorized))