   (start-http-server (-> app-routes
                        wrap-cookies
                        wrap-params
+                       log-and-wrap-dir-index
                        wrap-ring-handler)
                      {:host "localhost" :port 8080 :websocket true}))

        ring.middleware.cookies
        [ring.middleware.params :only (wrap-params)]
        [clojure.data.json :only (read-json json-str)])
  (:use [ontrail summary auth crypto user exercise])
  (:gen-class)
  (:require [compojure.route :as route]
            [monger.collection :as mc]))

(defn json-response [data & [status]]
  {:status (or status 200)

      action
      (json-response {"error" "Authentication required"} 401))))

(defn to-log-entry [req]
  (str "HTTP " (get req :remote-addr) (get req :uri)))

(defn log-and-wrap-dir-index [handler]
  (fn [req]
    (log (to-log-entry req))
    (handler
     (update-in req [:uri]
                #(if (= "/" %) "/index.html" %)))))

(defroutes app-routes
  (GET "/rest/v1/summary/:user" [user] (json-response (get-overall-summary user)))
  (GET "/rest/v1/ex/:id" [id] (json-response (get-ex id)))
  (GET "/rest/v1/ex-list-all/:page" [page] (json-response (get-latest-ex-list {} page)))
