Fix tests

This commit is contained in:
Tommi Reiman 2017-11-12 15:56:07 +02:00
parent 9434dd08e7
commit e8ee224160

View file

@ -18,6 +18,7 @@
"Creates a ring-handler out of a ring-router. "Creates a ring-handler out of a ring-router.
Supports both 1 (sync) and 3 (async) arities." Supports both 1 (sync) and 3 (async) arities."
[router] [router]
(let [default-handler (constantly nil)]
(with-meta (with-meta
(fn (fn
([request] ([request]
@ -26,7 +27,7 @@
params (:params match) params (:params match)
result (:result match) result (:result match)
handler (or (-> result method :handler) handler (or (-> result method :handler)
(-> result :any :handler)) (-> result :any (:handler default-handler)))
request (cond-> (impl/fast-assoc request ::match match) request (cond-> (impl/fast-assoc request ::match match)
(seq params) (impl/fast-assoc :path-params params))] (seq params) (impl/fast-assoc :path-params params))]
(handler request)))) (handler request))))
@ -36,12 +37,12 @@
params (:params match) params (:params match)
result (:result match) result (:result match)
handler (or (-> result method :handler) handler (or (-> result method :handler)
(-> result :any :handler)) (-> result :any (:handler default-handler)))
request (cond-> (impl/fast-assoc request ::match match) request (cond-> (impl/fast-assoc request ::match match)
(seq params) (impl/fast-assoc :path-params params))] (seq params) (impl/fast-assoc :path-params params))]
(handler request respond raise)) (handler request respond raise))
(respond nil)))) (respond nil))))
{::router router})) {::router router})))
(defn get-router [handler] (defn get-router [handler]
(some-> handler meta ::router)) (some-> handler meta ::router))