From 8afbbee8130dda07b86642c99ed3cc5d2ce31e1e Mon Sep 17 00:00:00 2001 From: Tommi Reiman Date: Mon, 2 Oct 2017 17:53:07 +0300 Subject: [PATCH] fast-router -> single-static-path-router --- src/reitit/core.cljc | 16 ++++++++-------- test/cljc/reitit/core_test.cljc | 12 ++++++------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/reitit/core.cljc b/src/reitit/core.cljc index 672fb7f1..9b39df0c 100644 --- a/src/reitit/core.cljc +++ b/src/reitit/core.cljc @@ -213,16 +213,16 @@ (if-let [match (impl/fast-get lookup name)] (match params))))))) -(defn fast-router - "Creates a super-fast router of 1 static route(s) and optional +(defn single-static-path-router + "Creates a fast router of 1 static route(s) and optional expanded options. See [[router]] for available options" ([routes] - (fast-router routes {})) + (single-static-path-router routes {})) ([routes opts] (when (or (not= (count routes) 1) (some impl/wild-route? routes)) (throw (ex-info - (str ":fast-router requires exactly 1 static route: " routes) + (str ":single-static-path-router requires exactly 1 static route: " routes) {:routes routes}))) (let [[n :as names] (find-names routes opts) [[p meta result] :as compiled] (compile-routes routes opts) @@ -230,7 +230,7 @@ match (->Match p meta result {} p)] (reify Router (router-name [_] - :fast-router) + :single-static-path-router) (routes [_] compiled) (options [_] @@ -248,7 +248,7 @@ (impl/fast-assoc match :params params))))))) (defn mixed-router - "Creates two routers: [[lookup-router]] or [[fast-ruoter]] for + "Creates two routers: [[lookup-router]] or [[single-static-path-router]] for static routes and [[linear-router]] for wildcard routes. All routes should be non-conflicting. Takes resolved routes and optional expanded options. See [[router]] for options." @@ -256,7 +256,7 @@ (mixed-router routes {})) ([routes opts] (let [{linear true, lookup false} (group-by impl/wild-route? routes) - ->static-router (if (= 1 (count lookup)) fast-router lookup-router) + ->static-router (if (= 1 (count lookup)) single-static-path-router lookup-router) wildcard-router (linear-router linear opts) static-router (->static-router lookup opts) names (find-names routes opts)] @@ -304,7 +304,7 @@ all-wilds? (every? impl/wild-route? routes) router (cond router router - (and (= 1 (count routes)) (not wilds?)) fast-router + (and (= 1 (count routes)) (not wilds?)) single-static-path-router (not wilds?) lookup-router all-wilds? linear-router (not conflicting) mixed-router diff --git a/test/cljc/reitit/core_test.cljc b/test/cljc/reitit/core_test.cljc index defae379..669b988c 100644 --- a/test/cljc/reitit/core_test.cljc +++ b/test/cljc/reitit/core_test.cljc @@ -70,9 +70,9 @@ (r/resolve-routes ["/api/:version/ping"] {}))))))) - (testing "fast-router" + (testing "single-static-path-router" (let [router (r/router ["/api" ["/ipa" ["/large" ::beer]]])] - (is (= :fast-router (r/router-name router))) + (is (= :single-static-path-router (r/router-name router))) (is (= [["/api/ipa/large" {:name ::beer} nil]] (r/routes router))) (is (= true (map? (r/options router)))) @@ -94,16 +94,16 @@ (testing "can't be created with wildcard routes" (is (thrown-with-msg? ExceptionInfo - #":fast-router requires exactly 1 static route" - (r/fast-router + #":single-static-path-router requires exactly 1 static route" + (r/single-static-path-router (r/resolve-routes ["/api/:version/ping"] {}))))) (testing "can't be created with multiple routes" (is (thrown-with-msg? ExceptionInfo - #":fast-router requires exactly 1 static route" - (r/fast-router + #":single-static-path-router requires exactly 1 static route" + (r/single-static-path-router (r/resolve-routes [["/ping"] ["/pong"]] {})))))))