                        :metadata       metadata}
                       context
                       (assoc :context (string/join "/" (cons "" context))))
-            handlers' (assoc handlers handler-sym handler)]
+            handlers' (assoc handlers handler-key handler)]
         [routes' handlers' middleware']))))
 
 (defn- analyse-dispatch-table

  "Returns a dispatch-map for use with map-traversal-dispatcher."
  [{:keys [routes handlers middleware]}
   {:keys [async? arg-symbol->resolver resolver-factories]}]
  (reduce (fn [dispatch-map [[method pathvec] handler-sym]]
            (t/track #(format "Compiling handler for `%s'." (get-in handlers [handler-sym :verb-fn-sym]))
                     (let [apply-middleware (if async?
                                              apply-middleware-async
                                              apply-middleware-sync)

  (if-let [[method pathvec verb-fn-sym mw-spec] dispatch-table-entry]
    (t/track
      (format "Analyzing resource handler function `%s'." verb-fn-sym)
      (let [handler-key (gensym "handler-key__")
            routes' (assoc routes
                      [method (keywords->symbols pathvec)] handler-key)
            [middleware' middleware-key] (if (contains? middleware mw-spec)
                                   [middleware (get middleware mw-spec)]
                                   (let [mw-sym (gensym "middleware-key__")]
