Skip to content

Commit

Permalink
rename collect-response to augment-map and added docs for it
Browse files Browse the repository at this point in the history
  • Loading branch information
wilkerlucio committed Nov 10, 2016
1 parent 1ba9d28 commit e19d460
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/untangled/server/impl/components/handler.clj
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,11 @@
(assoc acc k v)))
{} resp))

(defn collect-response [data]
(->> (keep #(some-> (second %) meta :untangled.server.core/augment-response) data)
(defn augment-map
"Parses response the top level values processing the augmented response. This function
expects the parser mutation results to be raised (use the raise-response function)."
[response]
(->> (keep #(some-> (second %) meta :untangled.server.core/augment-response) response)
(reduce (fn [response f] (f response)) {})))

(defn api
Expand All @@ -95,7 +98,7 @@
[{:keys [transit-params parser env] :as req}]
(let [parse-result (try (raise-response (parser env transit-params)) (catch Exception e e))]
(if (valid-response? parse-result)
(merge {:status 200 :body parse-result} (collect-response parse-result))
(merge {:status 200 :body parse-result} (augment-map parse-result))
(process-errors parse-result))))

(defn generate-response
Expand Down

0 comments on commit e19d460

Please sign in to comment.