I was more thinking about a single entry point into the routes.
Something like:
(defn sys1 [request] ...)
(defn sys2 [request] ...)
(defn handler1 [request] ...)
(defn handler2 [request] ...)
(defn handler3 [request] ...)
...
(defn handler10 [request] ...)
(defroutes system
(PUT "/foo" sys1)
(DELETE "/bar" sys2))
(decorate system
(handler1)
(handler2)
...
(handler10))
This is what I currently do in Compojure. The decorate will set up
handlers that run before the routes. And as I saw it begins with
the last decorated handler (handler10) and goes down to the first
one (handler1).
When now my defns above are instead anonymous functions then my
routes and their decoration could also be anon, or get a dummy
name. The route functions and the handler functions could all go
into a Map for example.
When I then want to make an update, I will put the updated functions
in a new Map and update:
(def routes2 {:sys1 (fn [request] ...), :sys2 (fn [request] ...)})
(def handlers2 {:handler7 (fn [request] ...) ...})
(defroutes temp3
(PUT "/foo" (:sys1 routes2))
(DELETE "/bar" (:sys2 routes2)))
(decorate temp3
(:handler1 handlers2)
(:handler2 handlers2)
...
(:handler10 handlers2))
(entry-point temp3)
A way to have multiple routes and handlers existing at the same
time would be good. And one single command would only do a reset!
on an atom, to decide at which function it starts. Then I can leave
all existing functions continue the handling of their current
requests and get the new ones online.
And the entry-point function or maybe def-entry-point macro could
also track how many requests are currently handled. A simple atom
that gets inc'ed when a new request enters the first handler, and
when the request got sent out the atom counter gets dec'ed.
Then entry-point can take a function which gets called as soon the
counter gets dec'ed to 0.
This function could be one that removes all references to the
vectors/maps of anon routes/handlers, so they can be garbage
collected.
(entry-point temp3
(fn []
(ns-unmap 'my.namespace 'routes2)
(ns-unmap 'my.namespace 'handlers2)))
I don't know the architecture of Compojure well enough.. but maybe
an addition of an entry-point function or a def-entry-point macro
can do the job?