Michael,
It depends how you work. If you work in an editor with an integrated
repl, you can simply edit and recompile your routes without restarting
your web server or repl.
When the interceptor that handles routing gets created, it is given
either a route table or a function that can be called to get a route
table. In dev mode, we give the router a fn that returns the latest
compiled route table. So if you change the route definition and
recompile the route table, the changes will be used for next request.
You don't have to restart the web server or the repl.
The lein pedestal-service template sets up dev mode for you, check out
the generated dev/dev.clj file, which includes this:
(def service (-> service/service
(merge {:env :dev
::bootstrap/join? false
::bootstrap/routes #(deref #'service/routes)})
(bootstrap/default-interceptors)
(bootstrap/dev-interceptors)))
This code takes the map that configures your production service and
modifies it for dev use. Note that it sets the value of the
:bootstrap/routes key with an anonymous fn that returns the latest
compiled routes.
But all of this assumes you are in an environment that makes it easy
to edit and recompile, like emacs. If you run a standalone editor and
a command line repl in a separate process, this approach doesn't work.
We have a proof-of-concept for a router that reloads routes from a
saved file, without explicitly recompiling. It also reloads the
namespaces you depend on, but not the ones they depend on. That could
certainly be done, but we stopped short because it wasn't clear we
need this functionality and because constantly reloading all your
namespaces requires some discipline in structuring your code.
Internally, we mostly use emacs.
Which mode to you work in?
Tim-