defroutes is a macro , so unfortunately you cannot pass it to a function such as a map. You will need to write a macro that would be extended in the defroutes call. or look at the functions that it expands and call them directly.
It will not work to create a list of routes in a call for a U-turn, like this
(defroutes public-routes (make-list-of-routes)
will expand to the list of routes:
(defroutes public-routes ( (GET "/" [] (info/index-template)) (GET "/about" [] (info/about-template)) (GET "/contact" [] (info/contact-template))) )
if defroutes where the normal function you would solve with apply
(apply defroutes (conj 'public-routes (make-list-of-routes)))
because defroutes is a macro that is fully completed before it can be applied, and the results will not make much sense. You really can't compose macros as functions. macros are not first-class citizens in clojure (or any lisp I know) When some kluurs (usually not me) say "Macros are evil", they often think of situations where you are faced with the fact that something is a macro when you try to compose it and cannot.
the solution is to not use the defroutes macro and directly call the routes function.
source share