                   (-> ~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)

  (:require [clojure.core.match :refer [match]]
            [clojure.string :as string]
            [clojure.pprint :as pp]
            [io.aviso.rook :as rook]
            [io.aviso.rook.async :as async]
            [io.aviso.rook.internals :as internals]
            [io.aviso.rook.schema-validation :as sv]))

(def ^:private default-mappings
