mirror of
https://github.com/metosin/reitit.git
synced 2025-12-23 18:41:11 +00:00
Don't test for nil handler
* it's already verified by the ring-router
This commit is contained in:
parent
63848838d5
commit
9434dd08e7
1 changed files with 12 additions and 12 deletions
|
|
@ -14,7 +14,10 @@
|
||||||
[top (assoc childs k v)]
|
[top (assoc childs k v)]
|
||||||
[(assoc top k v) childs])) [{} {}] meta))
|
[(assoc top k v) childs])) [{} {}] meta))
|
||||||
|
|
||||||
(defn ring-handler [router]
|
(defn ring-handler
|
||||||
|
"Creates a ring-handler out of a ring-router.
|
||||||
|
Supports both 1 (sync) and 3 (async) arities."
|
||||||
|
[router]
|
||||||
(with-meta
|
(with-meta
|
||||||
(fn
|
(fn
|
||||||
([request]
|
([request]
|
||||||
|
|
@ -23,23 +26,20 @@
|
||||||
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))
|
||||||
(if handler
|
request (cond-> (impl/fast-assoc request ::match match)
|
||||||
(handler
|
(seq params) (impl/fast-assoc :path-params params))]
|
||||||
(cond-> (impl/fast-assoc request ::match match)
|
(handler request))))
|
||||||
(seq params) (impl/fast-assoc :path-params params)))))))
|
|
||||||
([request respond raise]
|
([request respond raise]
|
||||||
(if-let [match (r/match-by-path router (:uri request))]
|
(if-let [match (r/match-by-path router (:uri request))]
|
||||||
(let [method (:request-method request :any)
|
(let [method (:request-method request :any)
|
||||||
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))
|
||||||
(if handler
|
request (cond-> (impl/fast-assoc request ::match match)
|
||||||
(handler
|
(seq params) (impl/fast-assoc :path-params params))]
|
||||||
(cond-> (impl/fast-assoc request ::match match)
|
(handler request respond raise))
|
||||||
(seq params) (impl/fast-assoc :path-params params))
|
|
||||||
respond raise)))
|
|
||||||
(respond nil))))
|
(respond nil))))
|
||||||
{::router router}))
|
{::router router}))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue