summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/reverse_routing/core.clj10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/reverse_routing/core.clj b/src/reverse_routing/core.clj
index 1977b2a..edc1f57 100644
--- a/src/reverse_routing/core.clj
+++ b/src/reverse_routing/core.clj
@@ -45,8 +45,9 @@
lookup-fn `(fn [[route-name# args#]]
(if (>= (count args#) ~keylen)
(let [~args args#
- r# (#'lookup-route [route-name# (vec (drop ~keylen args#))]
- ~@routes)
+ r# (try (#'lookup-route [route-name# (vec (drop ~keylen args#))]
+ ~@routes)
+ (catch Exception _#))
{uri# :uri, args# :args} r#]
(if r#
(assoc r#
@@ -68,6 +69,11 @@
(= (count args#) (count ~(vec route-args))))
~routes-map)))))
+(defmacro with-url-fn [f & body]
+ `(binding [*lookup-route* (fn [x#] (apply ~f x#))
+ *root* ""]
+ ~@body))
+
(defn url-for [route & arg-values]
(let [spec (*lookup-route* [route arg-values])
{:keys [uri type args]} spec