mirror of
https://github.com/metosin/reitit.git
synced 2026-01-02 06:38:26 +00:00
Cleanup code
This commit is contained in:
parent
e6beae52f0
commit
3d4737b3fb
1 changed files with 12 additions and 19 deletions
|
|
@ -38,18 +38,14 @@
|
|||
([routes]
|
||||
(walk ["" []] routes))
|
||||
([[pacc macc] routes]
|
||||
(let [subwalk (fn [path meta routes]
|
||||
(reduce
|
||||
(fn [acc route]
|
||||
(into acc (walk [path meta] route)))
|
||||
[]
|
||||
routes))]
|
||||
(letfn [(subwalk [p m r]
|
||||
(reduce #(into %1 (walk [p m] %2)) [] r))]
|
||||
(if (vector? (first routes))
|
||||
(subwalk pacc macc routes)
|
||||
(let [[path & [maybe-meta :as args]] routes]
|
||||
(let [[meta childs] (if-not (vector? maybe-meta)
|
||||
[maybe-meta (rest args)]
|
||||
[{} args])
|
||||
(let [[meta childs] (if (vector? maybe-meta)
|
||||
[{} args]
|
||||
[maybe-meta (rest args)])
|
||||
macc (into macc (expand meta))]
|
||||
(if (seq childs)
|
||||
(subwalk (str pacc path) macc childs)
|
||||
|
|
@ -58,16 +54,13 @@
|
|||
(defn map-meta [f routes]
|
||||
(mapv #(update % 1 f) routes))
|
||||
|
||||
(defn merge-meta
|
||||
([x]
|
||||
(merge-meta (constantly :into) x))
|
||||
([key-strategy x]
|
||||
(reduce
|
||||
(fn [acc [k v]]
|
||||
(let [strategy (or (key-strategy k) :replace)]
|
||||
(deep-merge strategy acc {k v})))
|
||||
{}
|
||||
x)))
|
||||
(defn merge-meta [key-strategy x]
|
||||
(reduce
|
||||
(fn [acc [k v]]
|
||||
(let [strategy (or (key-strategy k) :replace)]
|
||||
(deep-merge strategy acc {k v})))
|
||||
{}
|
||||
x))
|
||||
|
||||
(defn resolve-routes
|
||||
([x]
|
||||
|
|
|
|||
Loading…
Reference in a new issue