 (defroutes app-routes
   "Routes requests to their handler function. Captures dynamic variables."
   (GET "/summary/:user" [user] (json-response (get-overall-summary user)))
+  (POST "/login" [user password]
+    (if (authenticate user password)
+      (json-response {"success" "Authentication successful"} 200 (auth-token user password))
+      (json-response {"error" "Authentication failed"} 401)))
+
   (route/resources "/")
   (route/not-found "Page not found"))
 

(require '[monger.collection :as mc])
(use 'ring.middleware.file)
(use 'ring.middleware.cookies)
(use '[clojure.data.json :only (read-json json-str)])

(use '[ontrail.summary])

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

  all the routes we specified and is websocket ready."
  (start-http-server (-> app-routes
                       wrap-cookies
                       wrap-params
                       wrap-ring-handler)
                     {:host "localhost" :port 8080 :websocket true}))
