             [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]
+            [ring.util.response :as ring-resp]
             [io.pedestal.service.http.servlet :as ps]
             [io.pedestal.service.log :as log]
             ;; the impl dependencies will go away

; [[["/order"  ^:interceptors [verify-request] ^:constraints {:user-id #"[0-9]+"}
;    {:get list-orders :post create-order}
;    ["/:id"  ^:constraints {:user-id #"[0-9]+"} ^:interceptors [verify-order-ownership load-order-from-db]
;    {:get view-order :put update-order}]]]]
;;==================================================================================
(defroutes routes
  [[["/" {:get home-page}
     ; set common interceptors to be executed for all routes
     ^:interceptors [(body-params/body-params) bootstrap/html-body session-interceptor]
     ["/about" {:get about-page}]
     ["/api/schedule/:schedid" {:get get-schedule}]

;;==================================================================================
(defn add-schedule
  "add a schedule upon post request, request contains post data"
  [{postbody :edn-params :as request}]   ; xhr/request post data is edn encoded, not usable here.
  (let [;resp (bootstrap/json-print {:result msg-data})
        details (or postbody (:params request))  ; curl post body in :params
        added-schedule (scheduler/add-schedule details)
        result {:status 200 :schedule added-schedule}
        jsonresp (bootstrap/json-response result)
       ]
    ; INFO  minuette.service - {:line 52, "service add-schedule " {"detail" "123", "min" "3", "weekdays" "[1,2]"}
    (log/info "add-schedule request " request)
    jsonresp))
