Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

retain original handler result in metadata. #200

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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