I wanted to use a decision point :media-type-available?
but I failed...
I know I have to set the :representation :media-type
but I don't really know how to do it.
So far, my code looks as the following:
(defresource test-resource []
:media-type-available (fn [req]
(assoc req :representation {:media-type "application/json"}))
:available-media-types ["application/json" "text/html"]
:handle-ok (fn [req] {:ok true})
)
Remarks:
(assoc req :representation {:media-type "application/json"})
produces a correct map with "changed" req
object.:handle-ok
's req
object, the :representation
value is {}
I have no idea how to set it (it's not a mutable object, is it?) and looking at the liberator's source code doesn't really help...
Thanks, Karol
OK... It was just a typo... Instead of :representation
I had :represenation
...
So if anybody interested, there are two ways of solving this:
return req
object with merged :representation
:
:media-type-available (fn [req]
(assoc req :representation {:media-type "application/json"}))
return only the :representation
object:
:media-type-available (fn [req]
{:representation {:media-type "application/json"}})