 (ns calfpath.internal
   (:require [clojure.string :as str]))
+
+
+(defn expected
+  ([expectation found]
+    (throw (IllegalArgumentException.
+             (format "Expected %s, but found (%s) %s" expectation (class found) (pr-str found)))))
+  ([pred expectation found]
+    (when-not (pred found)
+      (expected expectation found))))
 
 
 (defn parse-uri-template

         ~default-expr)))
  ([method-keyword request expr default-expr]
    (when-not (valid-method-keys method-keyword)
      (throw (IllegalArgumentException.
               (str "Expected a method key (" valid-method-keys "), but found (" (class method-keyword) ") "
                 (pr-str method-keyword)))))
    `(if (identical? ~method-keyword (:request-method ~request))
       ~expr
       ~default-expr)))

    (and (vector? uri-pattern-or-template)
      (every? (some-fn string? keyword?)
        uri-pattern-or-template))          uri-pattern-or-template
    :otherwise                             (expected "a string URI pattern or a parsed URI template"
                                             uri-pattern-or-template)))


(def valid-method-keys #{:get :head :options :put :post :delete})
