 (def default-context {:translator (t/translations-fn t/translation-map)})
 
 (defn not-found [request]
-  (-> (html-response (error/not-found-error default-context))
+  (-> (sh/html-response (error/not-found-error default-context))
       (r/status 404)))
 
 (defn err-handler [request]
-  (-> (html-response (error/internal-server-error default-context))
+  (-> (sh/html-response (error/internal-server-error default-context))
       (r/status 500)))
 
 (defn csrf-err-handler [req]
-  (-> (html-response (error/csrf-error default-context))
+  (-> (sh/html-response (error/csrf-error default-context))
       (r/status 403)))
 
 (def site-handlers

  (csrf-err-handler req))

(def wrap-defaults-config
  (-> site-defaults
      (assoc-in [:session :cookie-attrs :max-age] 3600)
      (assoc-in [:session :cookie-name] "stonecutter-session")
      (assoc-in [:security :anti-forgery] {:error-handler handle-anti-forgery-error})))

(defn create-site-app [dev-mode?]
  (-> (scenic-handler routes site-handlers not-found)
      (wrap-defaults wrap-defaults-config)
      m/wrap-translator
      (m/wrap-error-handling err-handler dev-mode?)
      ))

(defn create-api-app [dev-mode?]
  (-> (scenic-handler routes api-handlers not-found)
      (wrap-defaults api-defaults)
      (m/wrap-error-handling err-handler dev-mode?)))                   ;; TODO create json error handler

(defn create-app [& {dev-mode? :dev-mode?}]

(ns stonecutter.handler
  (:require [ring.middleware.defaults :as ring-mw]
            [ring.util.response :as r]
            [ring.adapter.jetty :as ring-jetty]
            [environ.core :as env]
            [scenic.routes :as scenic]
            [clojure.tools.logging :as log]
            [stonecutter.view.error :as error]
            [stonecutter.view.view-helpers :as vh]
            [stonecutter.db.storage :as s]
            [stonecutter.helper :as sh]
            [stonecutter.routes :as routes]
            [stonecutter.logging :as log-config]
            [stonecutter.client :as client]
            [stonecutter.controller.user :as user]
