    [compojure.route :as route]
    [ring.middleware.session.cookie :refer (cookie-store)]
    [cemerick.friend :as friend]
+   (cemerick.friend [workflows :as workflows]
+                    [credentials :as creds])
    [com.stuartsierra.component :as component]
    [org.httpkit.server :refer (run-server)]
    [kixi.hecuba.web-paths :refer (compojure-route amon-index-route amon-resource-route)]
-   [kixi.hecuba.security :as sec]
+   [kixi.hecuba.security :as security]
    [kixi.hecuba.session :refer (cassandra-store)]
    
    [kixi.hecuba.api.programmes :as programmes]

   (resource-route :entity-device-measurement-readingtype-hourly-rollups [:entity_id :device_id :type] (rollups/hourly_rollups store))

   ;; Daily Measurements
   (resource-route :entity-device-measurement-readingtype-daily-rollups [:entity_id :device_id :type] (rollups/daily_rollups store))

   ;; 404 - if nothing else matches, then this is the end, my friend.
   (route/not-found not-found-page)))

(defrecord Routes [context]
  component/Lifecycle
  (start [this]
    (let [store  (:store this)
          app    (-> (app-routes store)
                     (sec/friend-middleware store)
                     (handler/site {:session {:store (cassandra-store store)}}))
          server (run-server app {:port 8010})]
      (assoc this ::server server)))
  (stop [this]
    ((::server this))))

         params
         handler)))

(defn amon-api-routes [store]
  (routes
   ;; API
   ;; Programmes
   (index-routes :programmes-index (programmes/index store))
