       (.equalsIgnoreCase (name method) form-method)
       (= method request-method))))
 
-(defn- if-method
-  "Evaluate the handler if the request method matches."
-  [method handler]
+(defn- if-method [method handler]
   (fn [request]
     (cond
       (or (nil? method) (method-matches? method request))

            [clout.core :as clout]
            [ring.util.codec :as codec]))

(defn- method-matches?
  "True if this request matches the supplied request method."
  [method request]
  (let [request-method (request :request-method)
        form-method    (or (get-in request [:form-params "_method"])
                           (get-in request [:multipart-params "_method"]))]

(defn- decode-route-params [params]
  (into {} (for [[k v] params] [k (codec/url-decode v)])))

(defn- assoc-route-params [request params]
  (merge-with merge request {:route-params params, :params params}))

(defn- if-route [route handler]
  (fn [request]
    (if-let [params (clout/route-matches route request)]
      (handler (assoc-route-params request (decode-route-params params))))))

(defn- prepare-route [route]
  (cond
    (string? route)
      `(clout/route-compile ~route)
