diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/abra/core.clj (renamed from src/reverse_routing/core.clj) | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/reverse_routing/core.clj b/src/abra/core.clj index edc1f57..3d373eb 100644 --- a/src/reverse_routing/core.clj +++ b/src/abra/core.clj @@ -1,4 +1,4 @@ -(ns reverse-routing.core +(ns abra.core (:require clout.core compojure.core [clojure.string :as string])) @@ -69,6 +69,15 @@ (= (count args#) (count ~(vec route-args)))) ~routes-map))))) +(defn add-middleware [handler middleware & args] + (let [result (apply middleware handler args)] + (vary-meta result + assoc ::lookup (fn [[name args]] + (let [lookup-fn (-> (deref-if-var handler) + meta + ::lookup)] + (lookup-fn [name args])))))) + (defmacro with-url-fn [f & body] `(binding [*lookup-route* (fn [x#] (apply ~f x#)) *root* ""] |