mirror of
https://github.com/metosin/reitit.git
synced 2025-12-29 04:38:26 +00:00
Inject Match and Router under reitit.core ns in ring
This commit is contained in:
parent
cb5e4d1177
commit
3005e04a6e
1 changed files with 13 additions and 9 deletions
|
|
@ -32,7 +32,7 @@
|
|||
([{:keys [not-found method-not-allowed not-acceptable]}]
|
||||
(fn
|
||||
([request]
|
||||
(if-let [match (::match request)]
|
||||
(if-let [match (::r/match request)]
|
||||
(let [method (:request-method request :any)
|
||||
result (:result match)
|
||||
handler? (or (-> result method :handler) (-> result :any :handler))
|
||||
|
|
@ -40,7 +40,7 @@
|
|||
(error-handler request))
|
||||
(not-found request)))
|
||||
([request respond _]
|
||||
(if-let [match (::match request)]
|
||||
(if-let [match (::r/match request)]
|
||||
(let [method (:request-method request :any)
|
||||
result (:result match)
|
||||
handler? (or (-> result method :handler) (-> result :any :handler))
|
||||
|
|
@ -66,8 +66,10 @@
|
|||
result (:result match)
|
||||
handler (or (-> result method :handler)
|
||||
(-> result :any (:handler default-handler)))
|
||||
request (cond-> (impl/fast-assoc request ::match match)
|
||||
(seq path-params) (impl/fast-assoc :path-params path-params))
|
||||
request (-> request
|
||||
(impl/fast-assoc ::r/match match)
|
||||
(impl/fast-assoc ::r/router router)
|
||||
(cond-> (seq path-params) (impl/fast-assoc :path-params path-params)))
|
||||
response (handler request)]
|
||||
(if (nil? response)
|
||||
(default-handler request)
|
||||
|
|
@ -80,17 +82,19 @@
|
|||
result (:result match)
|
||||
handler (or (-> result method :handler)
|
||||
(-> result :any (:handler default-handler)))
|
||||
request (cond-> (impl/fast-assoc request ::match match)
|
||||
(seq path-params) (impl/fast-assoc :path-params path-params))]
|
||||
request (-> request
|
||||
(impl/fast-assoc ::r/match match)
|
||||
(impl/fast-assoc ::r/router router)
|
||||
(cond-> (seq path-params) (impl/fast-assoc :path-params path-params)))]
|
||||
(handler request respond raise))
|
||||
(default-handler request respond raise))))
|
||||
{::router router}))))
|
||||
{::r/router router}))))
|
||||
|
||||
(defn get-router [handler]
|
||||
(some-> handler meta ::router))
|
||||
(-> handler meta ::r/router))
|
||||
|
||||
(defn get-match [request]
|
||||
(::match request))
|
||||
(::r/match request))
|
||||
|
||||
(defn coerce-handler [[path data] {:keys [expand] :as opts}]
|
||||
[path (reduce
|
||||
|
|
|
|||
Loading…
Reference in a new issue