Search code examples
clojurering

How to make wrap-reload work for generated routes?


I learned that wrap-reload from ring needs to capture the var itself not the value, but what if my value is dynamically generated and not a top level var?

(defn -main [options]
  (let [app (make-app options)]
    ;; This won't work either:
    ;; (run-jetty (wrap-reload #'app))
    (run-jetty (wrap-reload app))
  ))

Solution

  • Clojure let bindings do not create a Var object, so you cannot use the trick of passing (var app) (or it's shortcut #'app) in place of the function object that app points to.

    Please see the following for more detail: When to use a Var instead of a function?