summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarlo Zancanaro <carlo@zancanaro.id.au>2014-02-13 23:36:36 +1100
committerCarlo Zancanaro <carlo@zancanaro.id.au>2014-02-13 23:36:36 +1100
commit17da9b9ce4a3e5354a6a8689c1e2ee4466b76e39 (patch)
treedbad842089c045f0c739c9e8cdd61fabb86205cc /src
parentedbe046445defc78420afeecd141820e1860c50e (diff)
Rename project to 'abra', add 'add-middleware' function to maintain reverse-routing through middleware stack
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* ""]