diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gallifrey/handler.clj | 27 | ||||
-rw-r--r-- | src/gallifrey/store.clj | 1 |
2 files changed, 14 insertions, 14 deletions
diff --git a/src/gallifrey/handler.clj b/src/gallifrey/handler.clj index 61bdd16..cef8f0d 100644 --- a/src/gallifrey/handler.clj +++ b/src/gallifrey/handler.clj @@ -40,14 +40,15 @@ (when (#{:put :delete} (-> ctx :request :request-method)) (-> ctx :request :params :actor empty?))) :exists? (fn [ctx] - (if-let [resource (store/get-entity @the-store type id - :t-t (parse-ts ctx :t-t) :t-k (parse-ts ctx :t-k))] - {::resource ((case type - "entity" serialize-entity - "relationship" serialize-relationship) resource)} - (when (and (= :put (-> ctx :request :request-method)) - (-> ctx :request :params :create not-empty)) - true))) + (let [put? (= :put (-> ctx :request :request-method))] + (if-let [resource (if put? + (store/get-entity @the-store type id :t-k (parse-ts ctx :t-k)) + (store/get-entity @the-store type id + :t-t (parse-ts ctx :t-t) :t-k (parse-ts ctx :t-k)))] + {::resource ((case type + "entity" serialize-entity + "relationship" serialize-relationship) resource)} + (when (and put? (-> ctx :request :params :create not-empty)) true)))) :existed? (fn [ctx] (entity-existed? type id :t-k (parse-ts ctx :t-k))) :handle-ok ::resource :can-put-to-missing? false @@ -80,11 +81,11 @@ (when-let [resource (not-empty (store/entity-history @the-store type id))] {::resource (map-vals (partial map #(-> % - (update :k-start str) - (update :k-end str) - (update :t-start str) - (update :t-end str) - compact)) resource)})) + (update :k-start str) + (update :k-end str) + (update :t-start str) + (update :t-end str) + compact)) resource)})) :handle-ok ::resource) (defresource entity-lifespan-endpoint [type id] diff --git a/src/gallifrey/store.clj b/src/gallifrey/store.clj index 4f10f7c..05ac202 100644 --- a/src/gallifrey/store.clj +++ b/src/gallifrey/store.clj @@ -1,4 +1,3 @@ - (ns gallifrey.store (:require [utilis.map :refer [compact map-keys map-vals]] [utilis.types.keyword :refer [->keyword]] |