diff options
author | Carlo Zancanaro <carlo@clearboxsystems.com.au> | 2013-09-09 02:08:28 +1000 |
---|---|---|
committer | Carlo Zancanaro <carlo@clearboxsystems.com.au> | 2013-09-09 02:08:28 +1000 |
commit | edbe046445defc78420afeecd141820e1860c50e (patch) | |
tree | d8effed6dcb29496e9fa5fb82d3c68439d5937ee /src | |
parent | 48138c786125f43a89ea0c61718de9cdd6da0b50 (diff) |
Some utilities for testing (when used in other libraries)
Diffstat (limited to 'src')
-rw-r--r-- | src/reverse_routing/core.clj | 10 |
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 |