         handler (compile-rule-handler (:handler accessrule))
         matcher (cond
                   (:pattern accessrule)
-                  (fn->multi [request]
+                  (fn [request]
                     (let [pattern (:pattern accessrule)
                           uri (:uri request)]
                       (when (and (matches-request-method request request-method)


                  (:uri accessrule)
                  (let [route (clout/route-compile (:uri accessrule))]
                    (fn->multi [request]
                      (let [match-params (clout/route-matches route request)]
                        (when (and (matches-request-method request request-method) match-params)
                          match-params))))

                  (:uris accessrule)
                  (let [routes (mapv clout/route-compile (:uris accessrule))]
                    (fn->multi [request]
                      (let [match-params (->> (map #(clout/route-matches % request) routes)
                                              (filter identity)
                                              (first))]
                        (when (and (matches-request-method request request-method) match-params)
                          match-params))))

                  :else (fn->multi [request] {}))]
    (assoc accessrule
           :matcher matcher
           :handler handler)))

  "Access Rules system for ring based applications."
  (:require [buddy.auth :refer [throw-unauthorized]]
            [buddy.auth.http :as http]
            [clojure.walk :refer [postwalk]]
            [clout.core :as clout]))

