I've been working with Compojure and Ring lately to build an app
server, and I've gotten my brain stuck trying to figure out wrap-
reload.  It seems like I have to turn my routes into vars to get wrap-
reload to work, but I don't understand why, and I suppose I don't
really understand the "when" or "where" of the situation either.

For example, if I have a bunch of resource namespaces with
(defroutes ...) calls in them, and a main "core" namespace that
aggregates them all, wrap-reload will work in a scenario like this:

(defroutes combined
  #'myapp.resource.users
  #'myapp.resource.products
  #'myapp.resource.other
  (route/resources "/")
  (route/not-found "Page not found"))

In the above, changing code in any of the resource namespaces auto-
reloads them.

But if I put two defroutes in the same namespace and try to "var" one
of them, wrap-reload fails:

(defroutes defaults
  (route/resources "/")
  (route/not-found "Page not found"))

(defroutes all-routes
  myapp.resource.users
  myapp.resource.products
  myapp.resource.other)

(defroutes combined
  #'all-routes
  defaults)

If I pass combined to (handler/site ...) in Compojure, wrap-reload
doesn't work.

And, if I take the original, and remove the vars, then try to call
handler/site and var that route, it doesn't work either:

(defroutes combined
  myapp.resource.users
  myapp.resource.products
  myapp.resource.other
  (route/resources "/")
  (route/not-found "Page not found"))

(def app (handler/site #'combined))

What am I not understanding here?  I feel like this is the area I
struggle with most, and I'm not getting it at all.

P.S.  Please don't point me at lein-ring and have me just run that.
I'm trying to finally understand this, and I also need to be able to
access the REPL in the same classloader as the running server for
other reasons.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to