Open jamesmintram opened 7 years ago
Looks like the callstack I was getting was wrong. The error was caused several method calls deeper than the reponse fn - looks like the comment here is related? :) https://github.com/juxt/yada/blob/master/src/yada/methods.clj#L34
Hi @jamesmintram - thanks for this report. The purpose of the code is to be a little more relaxed about calling response functions that don't have the exact signature - say you're not using the ctx you can use a no-args fn. The strategy is to attempt to call the (fn [ctx])
form first, for performance reasons, and then try other forms. However, if there's an ArityException in your response function, then this might lead to the function being called twice.
Reopening to consider whether to remove this code strategy and require response functions to be single-arity.
If single arity response functions were to be enforced, then the "arity" method would need to handle the case of partially applied functions too (instead of returning 0).
I "fixed" this problem in my fork... but I do not know whether it is a good fix or bad one :) I can share it later when I have access to my machine at home.
https://github.com/juxt/yada/blob/master/src/yada/util.clj#L241 returns 0 for a partial function. This leads to an Arity error when requesting the resource.