mirror of
https://github.com/metosin/reitit.git
synced 2026-02-04 11:23:14 +00:00
:parts => :path-parts
This commit is contained in:
parent
54b24be28e
commit
20b9d3c6c8
2 changed files with 3 additions and 4 deletions
|
|
@ -100,7 +100,7 @@
|
||||||
(into [] (keep #(compile-route % opts) routes)))
|
(into [] (keep #(compile-route % opts) routes)))
|
||||||
|
|
||||||
(defn route-info [route]
|
(defn route-info [route]
|
||||||
(select-keys (impl/create route) [:path :parts :path-params :result :data]))
|
(select-keys (impl/create route) [:path :path-parts :path-params :result :data]))
|
||||||
|
|
||||||
(defprotocol Router
|
(defprotocol Router
|
||||||
(router-name [this])
|
(router-name [this])
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@
|
||||||
;; Routing (c) Metosin
|
;; Routing (c) Metosin
|
||||||
;;
|
;;
|
||||||
|
|
||||||
(defrecord Route [path matcher parts path-params data result])
|
(defrecord Route [path matcher path-parts path-params data result])
|
||||||
|
|
||||||
(defn create [[path data result]]
|
(defn create [[path data result]]
|
||||||
(let [path #?(:clj (.intern ^String path) :cljs path)]
|
(let [path #?(:clj (.intern ^String path) :cljs path)]
|
||||||
|
|
@ -110,7 +110,6 @@
|
||||||
:data data})
|
:data data})
|
||||||
(dissoc $ :path-re :path-constraints)
|
(dissoc $ :path-re :path-constraints)
|
||||||
(update $ :path-params set)
|
(update $ :path-params set)
|
||||||
(set/rename-keys $ {:path-parts :parts})
|
|
||||||
(map->Route $))))
|
(map->Route $))))
|
||||||
|
|
||||||
(defn wild-route? [[path]]
|
(defn wild-route? [[path]]
|
||||||
|
|
@ -130,7 +129,7 @@
|
||||||
(defn path-for [^Route route path-params]
|
(defn path-for [^Route route path-params]
|
||||||
(if-let [required (:path-params route)]
|
(if-let [required (:path-params route)]
|
||||||
(if (every? #(contains? path-params %) required)
|
(if (every? #(contains? path-params %) required)
|
||||||
(str "/" (str/join \/ (map #(get (or path-params {}) % %) (:parts route)))))
|
(str "/" (str/join \/ (map #(get (or path-params {}) % %) (:path-parts route)))))
|
||||||
(:path route)))
|
(:path route)))
|
||||||
|
|
||||||
(defn throw-on-missing-path-params [template required path-params]
|
(defn throw-on-missing-path-params [template required path-params]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue