                   (-> ~request-sym :rook :arg-resolvers)))])
     arglist))
 
+(defn apply-middleware-sync [middleware sync? handler]
+  (middleware handler))
+
+(defn apply-middleware-async [middleware sync? handler]
+  (middleware
+    (if sync?
+      (async/ring-handler->async-handler handler)
+      handler)))
+
 (defn compile-dispatch-table
   "Compiles the dispatch table into a Ring handler.
 

                                                   route-params
                                                   non-route-params)]
                                           (~verb-fn-sym ~@arglist)))]
                          ((~middleware handler#)
                           (assoc ~req
                             :route-params route-params#)))]))
                  dt)

  ([options dispatch-table]
     (let [dt  (unnest-dispatch-table dispatch-table)
           req (gensym "request__")
           emit-fn (:emit-fn options eval)
           apply-middleware (:apply-middleware-fn options
                                                  `apply-middleware-sync)]
       (emit-fn
         `(fn rook-dispatcher# [~req]
            (match (preparse-request ~req)
              ~@(mapcat
                  (fn [[method pathvec verb-fn-sym middleware]]
                    (let [metadata         (meta (resolve verb-fn-sym))
                          sync?            (:sync metadata)
                          pathvec          (keywords->symbols pathvec)
                          route-params     (set (filter symbol? pathvec))
                          arglist          (first (:arglists metadata))
