Skip to content

Commit

Permalink
Add raw handler result to response metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
Yannick Scherer committed Mar 3, 2015
1 parent 9b21024 commit f21a252
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/liberator/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@
{"Accept-Patch" (join "," ((:patch-content-types resource)))}
{})))

(defn handler-result->response
[{:keys [as-response]} context handler-result]
(when-let [response (as-response handler-result context)]
(vary-meta response assoc :liberator/value handler-result)))

(defn run-handler [name status message
{:keys [resource request representation] :as context}]
(let [context
Expand Down Expand Up @@ -172,12 +177,10 @@
;; override the status and headers.


(let [as-response (:as-response resource)]
(as-response
(if-let [handler (get resource (keyword name))]
(handler context)
(get context :message))
context)))))]
(->> (if-let [handler (get resource (keyword name))]
(handler context)
(get context :message))
(handler-result->response resource context)))))]
(cond
(or (= :options (:request-method request)) (= 405 (:status response)))
(merge-with merge
Expand Down

0 comments on commit f21a252

Please sign in to comment.