mirror of
https://github.com/metosin/reitit.git
synced 2025-12-25 03:08:25 +00:00
use linearrouter if all routes are wild
This commit is contained in:
parent
3dc1cdfbe2
commit
dd6d0d5a1c
2 changed files with 5 additions and 3 deletions
|
|
@ -256,9 +256,11 @@
|
|||
routes (resolve-routes data opts)
|
||||
conflicting (conflicting-routes routes)
|
||||
wilds? (some impl/wild-route? routes)
|
||||
all-wilds? (every? impl/wild-route? routes)
|
||||
router (cond
|
||||
router router
|
||||
(not wilds?) lookup-router
|
||||
all-wilds? linear-router
|
||||
(not conflicting) mixed-router
|
||||
:else linear-router)]
|
||||
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@
|
|||
|
||||
(deftest reitit-test
|
||||
|
||||
(testing "mixed router"
|
||||
(testing "linear-router"
|
||||
(let [router (reitit/router ["/api" ["/ipa" ["/:size" ::beer]]])]
|
||||
(is (= :mixed-router (reitit/router-type router)))
|
||||
(is (= :linear-router (reitit/router-type router)))
|
||||
(is (= [["/api/ipa/:size" {:name ::beer}]]
|
||||
(reitit/routes router)))
|
||||
(is (= true (map? (reitit/options router))))
|
||||
|
|
@ -40,7 +40,7 @@
|
|||
#"^missing path-params for route /api/ipa/:size: \#\{:size\}$"
|
||||
(reitit/match-by-name! router ::beer))))))
|
||||
|
||||
(testing "lookup router"
|
||||
(testing "lookup-router"
|
||||
(let [router (reitit/router ["/api" ["/ipa" ["/large" ::beer]]])]
|
||||
(is (= :lookup-router (reitit/router-type router)))
|
||||
(is (= [["/api/ipa/large" {:name ::beer}]]
|
||||
|
|
|
|||
Loading…
Reference in a new issue