I am writing a clojure function that works fine when I am using defnto define it, but it throws arity error when instead I define it using defresource. I suspect it's something to do with the :as-response key that I am using but I have no clue how to fix it.
Any ideas?
My code:
(defn function-name []
:allowed-methods [:get]
:available-media-types ["application/json"]
:as-response (my function is here))
Error when using defresource: "Wrong number of args (2) passed to ... " I am passing 0 arguments which works fine using defn.
The
defnthat you’ve defined is equivalent toSince the value of the
doexpression is the last form in the expression — and the keywords and vectors don’t have any side effects — the function definition is equivalent toWhat you have is a 0-parameter arity function. The
:as-responseand other keywords / vectors don’t do anything.Looking at the documentation for Liberator, the library expects a 2-parameter arity function when using
:as-response. Also according to the documentation on resources you only need to pass a parameter vector todefresourceif you’d like a parameterized resource. So your resource should be defined