You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(defresource ticket-resource
:method-allowed? (request-method-in :get)
:available-media-types ["text/plain"]
:exists? (fn [{{id :id} :params} :request}]
(if-let [ticket (get-ticket-by-id id)]
{::ticket ticket})) ;; associate in context
:handle-ok ::ticket ;; use the keyword as a function
:handle-not-found "ticket not found")
Currently does not work because liberator tries to coerce ::ticket to a Representation. It would be nice if it would work exactly like :handle-ok #(::ticket %)
The text was updated successfully, but these errors were encountered:
It seems like this already works. At least for :handle-ok. I wrote the following facts/fixtures to prove it to myself. Would you be interested in a PR that adds the test below?
(defresource with-keyword-handler
:exists? {::important-message "#yolo"}
:handle-ok ::important-message)
(fact "keyword handlers should return their entry in the context"
(with-keyword-handler {:request-method :get})
=> {:headers {"Content-Type" "text/plain;charset=UTF-8"}, :body "#yolo", :status 200})
Currently does not work because liberator tries to coerce ::ticket to a Representation. It would be nice if it would work exactly like
:handle-ok #(::ticket %)
The text was updated successfully, but these errors were encountered: