can edit.

This commit is contained in:
Bryce Covert
2018-04-14 09:46:36 -07:00
parent b6b7b1932a
commit 5ab67c5887
3 changed files with 139 additions and 27 deletions

View File

@@ -10,7 +10,7 @@
[clj-time.periodic :as p]
[clj-time.predicates :as pred]
[clojure.data.json :as json]
[compojure.core :refer [GET POST context defroutes
[compojure.core :refer [GET PUT POST context defroutes
wrap-routes]])
(:import (org.joda.time DateTime)))
@@ -52,6 +52,7 @@
(defroutes routes
(context "/reminders" []
(POST "/send" {:keys [query-params headers body] :as x}
(let [notification-type (get headers "x-amz-sns-message-type")]
(println "Received notification " notification-type)
@@ -70,9 +71,14 @@
{:status 200
:body "{}"
:headers {"Content-Type" "application/edn"}})
(wrap-routes (GET "/" {:keys [query-params]}
{:status 200
:body (pr-str (map replace-joda (reminders/get-all)))
:headers {"Content-Type" "application/edn"}})
wrap-secure)))
(wrap-routes
(PUT "/:id" {:keys [ edn-params] {:keys [id] } :route-params}
(let [id (if (int? id)
id
(Integer/parseInt id))]
(assert (not (:sent (reminders/get-by-id id))))
(reminders/update! id edn-params)
{:status 200
:body "{}"
:headers {"Content-Type" "application/edn"}}))
wrap-secure)))