                               merge (dissoc metadata :arg-resolvers))
                             ;; FIXME
                             (cond-> context
-                              (update-in [:context] str context)))))
-
-                  pathvec' (mapv #(if (variable? %) ::param-next %) pathvec)
-
-                  dispatch-path (conj 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)]
-              (reduce (fn [dispatch-map [name path]]
-                        (assoc-in dispatch-map path (keyword name)))
-                (assoc-in dispatch-map dispatch-path h)
-                (map vector binding-names binding-paths))))
+                              (update-in [:context] str context)))))]
+              (add-dispatch-entries dispatch-map method pathvec h)))
     {}
     routes))
 

              (maybe-resolver-by-tag arg)))
      arglist)))

(defn build-dispatch-map
  "Returns a dispatch-map for use with map-traversal-dispatcher."
  [{:keys [routes handlers middleware]}
   {:keys [async?]}]
  (reduce (fn [dispatch-map [[method pathvec] handler-sym]]
            (let [ensure-fn #(if (fn? %) % (eval %))
                  apply-middleware (if async?
                                     apply-middleware-async
                                     apply-middleware-sync)


                                 (resolvers-for arglist (:resolvers metadata))
                                 route-params)

                  mw (applicable-middleware
                       (get middleware middleware-sym)
                       arg-resolvers)

                  f  (let [ef (eval verb-fn-sym)]
                       (fn wrapped-handler [request]
                         (apply ef (resolve-args request))))

                  h  (apply-middleware mw sync? f)
                  h  (fn wrapped-with-rook-metadata [request]
                       (h (-> request
