                                           (assoc m term i)
                                           m))
                                       {}
-                                      path)]
+                                      path)
+              ;; Only these two keys are needed by the map traversal dispatcher, so there's no reason to keep
+              ;; the full metdata of the endpoint.
+              endpoint-meta' (select-keys endpoint-meta [:function :match])]
           (update-in dispatch-map path'
-                     conj' [handler endpoint-meta route-params])))
+                     conj' [handler endpoint-meta' route-params])))
       {}
-      routing-table)))
+      routing-specs)))
 
 (defn- endpoint-filter
   [request [_ {endpoint-matcher :match}]]


  The handler-wrapper is a special middleware placed *before* any normal middleware for the
  endpoint. For synchronous Rook, it is always identity. For async Rook, it converts
  a synchronous handler into an asynchronous handler, using the core.async thread macro."
  [handler-wrapper ns-table]
  (mapcat (partial expand-namespace-entry handler-wrapper) ns-table))

(defn- construct-dispatch-map
  "Constructs the dispatch map from the handlers. The structure of the dispatch map
  is a tree. Each node on the tree is a map.

  String keys in a node are literal terms in the path, the value is a nested nodes.

  The :_ key in a node represents a position of a path argument, the value is a nested node.

  The other keys in a node are request methods (:get, :put, etc., or :all). The value
  is a vector of handler data, each of which is a vector of [handler endpoint-meta route-params]."
  [routing-table]
  (let [conj' (fnil conj [])]
    (reduce
      (fn [dispatch-map [method path handler endpoint-meta]]

                             (if async?
                               (get options :sync-wrapper default-sync-wrapper)
                               default-namespace-middleware)))
        handler (->>
                  routing-table
                  vals
                  (apply concat)
                  construct-dispatch-map
                  (create-map-traversal-handler
                    (if async? closed-channel)))]
    [handler routing-table]))