 (ns minuette.service
+  (:require [io.pedestal.service.http :as bootstrap]
+            [io.pedestal.service.http.route :as route]
+            [io.pedestal.service.http.route.definition :refer [defroutes]]
+            [io.pedestal.service.http.body-params :as body-params]
+            [ring.util.response :as ring-response]
+            [io.pedestal.service.http.servlet :as ps]
+            [io.pedestal.service.log :as log]
+            ;; the impl dependencies will go away
+            [io.pedestal.service.impl.interceptor :as interceptor]
+            [io.pedestal.service.interceptor :refer [definterceptor handler]]
+            [io.pedestal.service.http.impl.servlet-interceptor :as servlet-interceptor]
+            [io.pedestal.service.http.ring-middlewares :as middlewares]
+            ;; these next two will collapse to one
+            [io.pedestal.service.http.route :as route]
+            [io.pedestal.service.http.route.definition :refer [defroutes]]
+            [io.pedestal.service.http.sse :refer :all]
+            [ring.util.mime-type :as ring-mime]
+            [ring.middleware.session.cookie :as cookie])
     (:require [io.pedestal.service.http :as bootstrap]
               [io.pedestal.service.http.route :as route]
               [io.pedestal.service.http.body-params :as body-params]



;;==================================================================================
; POST form details to add a schedule
; reqbody is body when xhr-request on api service side
;;==================================================================================
(defn add-schedule
  "add a schedule upon post request, request contains post data"
  [{reqbody :edn-params :as request}]  ; reqbody is json post data
  (let [;resp (bootstrap/json-print {:result msg-data})
        added-schedule (scheduler/add-schedule (:details reqbody))
        result {:status 200 :schedule added-schedule}
        jsonresp (bootstrap/json-response result)
        ]
    ; INFO  minuette.service - {:line 52, "service add-schedule " nil}
    (log/info "add-schedule " request reqbody (:details reqbody))
    jsonresp))

;==================================================================================
;; define routing table with verb map and route interceptor
;;==================================================================================
(defroutes routes
  [[["/" {:get home-page}
     ;; Set default interceptors for /about and any other paths under /
     ^:interceptors [(body-params/body-params) bootstrap/html-body]
     ["/about" {:get about-page}]
     ["/api/schedule/:schedid" {:get get-schedule}]
     ["/api/schedule" {:post add-schedule}]

  (ring-resp/response "Hello World!"))


; gen uuid session id
(defn- gen-session-id [] (.toString (java.util.UUID/randomUUID)))

; session intercept to extract cookie.
(definterceptor session-interceptor
  (middlewares/session {:store (cookie/cookie-store)}))

;;==================================================================================
;
;;==================================================================================
