mirror of
https://github.com/metosin/reitit.git
synced 2026-02-09 21:13:13 +00:00
Fix tests
This commit is contained in:
parent
9434dd08e7
commit
e8ee224160
1 changed files with 25 additions and 24 deletions
|
|
@ -18,30 +18,31 @@
|
||||||
"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]
|
||||||
(with-meta
|
(let [default-handler (constantly nil)]
|
||||||
(fn
|
(with-meta
|
||||||
([request]
|
(fn
|
||||||
(if-let [match (r/match-by-path router (:uri request))]
|
([request]
|
||||||
(let [method (:request-method request :any)
|
(if-let [match (r/match-by-path router (:uri request))]
|
||||||
params (:params match)
|
(let [method (:request-method request :any)
|
||||||
result (:result match)
|
params (:params match)
|
||||||
handler (or (-> result method :handler)
|
result (:result match)
|
||||||
(-> result :any :handler))
|
handler (or (-> result method :handler)
|
||||||
request (cond-> (impl/fast-assoc request ::match match)
|
(-> result :any (:handler default-handler)))
|
||||||
(seq params) (impl/fast-assoc :path-params params))]
|
request (cond-> (impl/fast-assoc request ::match match)
|
||||||
(handler request))))
|
(seq params) (impl/fast-assoc :path-params params))]
|
||||||
([request respond raise]
|
(handler request))))
|
||||||
(if-let [match (r/match-by-path router (:uri request))]
|
([request respond raise]
|
||||||
(let [method (:request-method request :any)
|
(if-let [match (r/match-by-path router (:uri request))]
|
||||||
params (:params match)
|
(let [method (:request-method request :any)
|
||||||
result (:result match)
|
params (:params match)
|
||||||
handler (or (-> result method :handler)
|
result (:result match)
|
||||||
(-> result :any :handler))
|
handler (or (-> result method :handler)
|
||||||
request (cond-> (impl/fast-assoc request ::match match)
|
(-> result :any (:handler default-handler)))
|
||||||
(seq params) (impl/fast-assoc :path-params params))]
|
request (cond-> (impl/fast-assoc request ::match match)
|
||||||
(handler request respond raise))
|
(seq params) (impl/fast-assoc :path-params params))]
|
||||||
(respond nil))))
|
(handler request respond raise))
|
||||||
{::router router}))
|
(respond nil))))
|
||||||
|
{::router router})))
|
||||||
|
|
||||||
(defn get-router [handler]
|
(defn get-router [handler]
|
||||||
(some-> handler meta ::router))
|
(some-> handler meta ::router))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue