Hi, Thank you for the hint. I was taking some more time to look at other products and finally saw that luminus just uses ring.server.standalone/serve which supports auto reload for templates and clj code. So I just created two different components, one for development and one for runtime which uses http-kit.
This way I don't need the dynamic var at all. Best Regards, Sven Am Montag, 9. Februar 2015 15:20:20 UTC+1 schrieb Steve Ashton: > > I've had the same question. What I've come up with is to introduce a new > middleware in the the dev-system, which wraps the both the creation of the > app handler and calling the handler with the request map. The prod-system > would still refer directly to a single instance of the app handler. > > Now in dev-mode, on every request, a new handler is both created and > executed. There is a potential performance impact of re-creating the app > ring handlers, but I haven't noticed any issues yet, and this is only for > development mode, so I'm not too concerned about it. The improved repl > experience is valuable to me. > > Using your code: > > (defn app [] (app-handler > [home-routes user-routes base-routes] > :middleware (load-middleware) > :ring-defaults (mk-defaults false) > :access-rules [] > :formats [:json-kw :edn :transit-json])) > > (defn dev-system [] > (component/system-map > :web (new-web-server (env :http-port) (fn [] (fn [req] ((app) req))))) > > (defn prod-system [] > (component/system-map > :web (new-web-server (env :http-port) (app))) > > > > > > > > On Sunday, February 8, 2015 at 1:37:40 PM UTC-5, Sven Richter wrote: >> >> Hi, >> >> This is something that I am struggling for some time and I still don't >> know how to solve it. >> For dynamic reloading in web development there is this common pattern: >> >> (def app (app-handler >> [home-routes user-routes base-routes] >> :middleware (load-middleware) >> :ring-defaults (mk-defaults false) >> :access-rules [] >> :formats [:json-kw :edn :transit-json])) >> >> (defn get-handler [] >> (-> #'app >> (wrap-file "resources") >> (wrap-file-info))) >> >> >> >> This works nice, but does not give me components. With components I would >> do something like this: >> >> (defn app [] (app-handler >> [home-routes user-routes base-routes] >> :middleware (load-middleware) >> :ring-defaults (mk-defaults false) >> :access-rules [] >> :formats [:json-kw :edn :transit-json])) >> >> (defn dev-system [] >> (component/system-map >> :web (new-web-server (env :http-port) (app))) >> >> Reloading all components takes a bit more time and ceremony than just >> having it all reloaded by itself. (I don't wanna say it takes long, but for >> me this are 2 keystrokes more + ~1 second wait time versus no keystrokes >> and almost no wait time with dynamic var reloading). >> >> Is there a way to combine both approaches to get the best of both worlds? >> >> Thanks, >> Sven >> >> >> -- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.