            apply-middleware (:apply-middleware-fn options)
            build-handler    (:build-handler-fn options)
 
-           {:keys [routes handlers middleware]}
-           (analyse-dispatch-table dispatch-table)]
+           analysed-dispatch-table (analyse-dispatch-table dispatch-table)]
        (emit-fn
-         (build-handler routes handlers middleware apply-middleware)))))
+         (build-handler analysed-dispatch-table apply-middleware)))))
 
 (defn default-middleware [handler]
   (-> handler


  Can be passed to compile-dispatch-table using the :build-handler-fn
  option."
  [routes handlers middleware apply-middleware]
  (let [req (gensym "request__")
        tmp (gensym "tmp_var__")]
    `(do
       (def ~tmp
         (atom {:dispatch-map {}
                :endpoint-fns {}
                :middleware   {}}))
       ~@(map (fn [[mw-sym mw]]
                `(swap! ~tmp assoc-in [:middleware '~mw-sym] ~mw))
           middleware)
       ~@(mapcat
           (fn [[[method pathvec] handler-sym]]
             (let [handler-map (get handlers handler-sym)
                   mw-sym      (:middleware-sym handler-map)
                   schema      (:schema handler-map)
                   h `(let [~mw-sym (get-in @~tmp [:middleware '~mw-sym])]
                        ~(handler-form
                           apply-middleware req handler-sym handler-map))
                   dispatch-path (conj
                                   (mapv (fn [seg]
                                           (if (variable? seg)
                                             ::param-next
                                             seg))
                                     pathvec)
                                   method)
                   binding-names (filter variable? pathvec)
                   binding-paths (keep-indexed
                                   (fn [i seg]
                                     (if (variable? seg)
                                       (-> (subvec pathvec 0 i)
                                         (into [])
                                         (conj ::param-name))))
                                   pathvec)]
               `[(swap! ~tmp assoc-in [:endpoint-fns '~handler-sym] ~h)
                 (swap! ~tmp assoc-in
                   (into [:dispatch-map] ~dispatch-path)
                   '~handler-sym)
                 ~@(map (fn [name path]
                          `(swap! ~tmp
                             assoc-in
                             (into [:dispatch-map] ~path) ~(keyword name)))
                     binding-names
                     binding-paths)]))
           routes)
       (let [dispatch-map# (:dispatch-map @~tmp)
             endpoint-fns# (:endpoint-fns @~tmp)]
         (ns-unmap *ns* '~tmp)
         (map-traversal-dispatcher dispatch-map# endpoint-fns#)))))

(def dispatch-table-compilation-defaults
  {:emit-fn             eval


  Can be passed to compile-dispatch-table using the :build-handler-fn
  option."
  [{:keys [routes handlers middleware]} apply-middleware]
  (let [req (gensym "request__")]
    `(let [~@(apply concat middleware)
           ~@(mapcat (fn [[handler-sym handler-map]]
