diff --git a/doc/basics/route_data.md b/doc/basics/route_data.md index b615ab7c..2ea2f50e 100644 --- a/doc/basics/route_data.md +++ b/doc/basics/route_data.md @@ -147,7 +147,7 @@ Expanded routes: ``` -## Expansion +## Customizing Expansion By default, router `:expand` option has value `r/expand` function, backed by a `r/Expand` protocol. Expansion can be customized either by swapping the `:expand` implementation or by extending the Protocol. `r/Expand` implementations can be recursive. @@ -169,4 +169,4 @@ Page [shared routes](../advanced/shared_routes.md#using-custom-expander) has an ## Route data validation -See [Route data validation](route_data_validation.md), which enables an architecture of both [adaptive and principled](https://youtu.be/x9pxbnFC4aQ?t=1907) components. +See [Route data validation](route_data_validation.md). diff --git a/modules/reitit-core/java-src/reitit/Trie.java b/modules/reitit-core/java-src/reitit/Trie.java index 1c60987b..adc220e5 100644 --- a/modules/reitit-core/java-src/reitit/Trie.java +++ b/modules/reitit-core/java-src/reitit/Trie.java @@ -261,7 +261,7 @@ public class Trie { @Override public int depth() { - return Arrays.stream(childs).mapToInt(Matcher::depth).max().orElseThrow(NoSuchElementException::new); + return Arrays.stream(childs).mapToInt(Matcher::depth).max().orElseThrow(NoSuchElementException::new) + 1; } @Override diff --git a/modules/reitit-core/src/reitit/coercion.cljc b/modules/reitit-core/src/reitit/coercion.cljc index 01144de7..b9da1519 100644 --- a/modules/reitit-core/src/reitit/coercion.cljc +++ b/modules/reitit-core/src/reitit/coercion.cljc @@ -12,7 +12,7 @@ "Pluggable coercion protocol" (-get-name [this] "Keyword name for the coercion") (-get-options [this] "Coercion options") - (-get-apidocs [this spesification data] "Returns api documentation") + (-get-apidocs [this specification data] "Returns api documentation") (-compile-model [this model name] "Compiles a model") (-open-model [this model] "Returns a new model which allows extra keys in maps") (-encode-error [this error] "Converts error in to a serializable format") @@ -136,14 +136,14 @@ ;; api-docs ;; -(defn get-apidocs [this spesification data] +(defn get-apidocs [this specification data] (let [swagger-parameter {:query :query :body :body :form :formData :header :header :path :path :multipart :formData}] - (case spesification + (case specification :swagger (->> (update data :parameters @@ -152,7 +152,7 @@ (map (fn [[k v]] [(swagger-parameter k) v])) (filter first) (into {})))) - (-get-apidocs this spesification))))) + (-get-apidocs this specification))))) ;; ;; integration diff --git a/modules/reitit-core/src/reitit/interceptor.cljc b/modules/reitit-core/src/reitit/interceptor.cljc index 67b41510..7ef698df 100644 --- a/modules/reitit-core/src/reitit/interceptor.cljc +++ b/modules/reitit-core/src/reitit/interceptor.cljc @@ -44,7 +44,7 @@ "Available interceptors in registry:\n" (with-out-str (pprint/print-table [:id :description] (for [[k v] registry] {:id k :description v})))) - "see [reitit.interceptor/router] on how to add interceptor to the registry.\n") "\n") + "See [reitit.interceptor/router] on how to add interceptor to the registry.\n") "\n") {:id this :registry registry}))) diff --git a/modules/reitit-core/src/reitit/middleware.cljc b/modules/reitit-core/src/reitit/middleware.cljc index f4eaced8..44cf1a17 100644 --- a/modules/reitit-core/src/reitit/middleware.cljc +++ b/modules/reitit-core/src/reitit/middleware.cljc @@ -28,7 +28,7 @@ "Available middleware in registry:\n" (with-out-str (pprint/print-table [:id :description] (for [[k v] registry] {:id k :description v})))) - "see [reitit.middleware/router] on how to add middleware to the registry.\n") "\n") + "See [reitit.middleware/router] on how to add middleware to the registry.\n") "\n") {:id this :registry registry}))) diff --git a/modules/reitit-schema/src/reitit/coercion/schema.cljc b/modules/reitit-schema/src/reitit/coercion/schema.cljc index 9bd512f6..1985ba72 100644 --- a/modules/reitit-schema/src/reitit/coercion/schema.cljc +++ b/modules/reitit-schema/src/reitit/coercion/schema.cljc @@ -46,9 +46,9 @@ (reify coercion/Coercion (-get-name [_] :schema) (-get-options [_] opts) - (-get-apidocs [this spesification {:keys [parameters responses]}] + (-get-apidocs [this specification {:keys [parameters responses]}] ;; TODO: this looks identical to spec, refactor when schema is done. - (case spesification + (case specification :swagger (swagger/swagger-spec (merge (if parameters @@ -69,8 +69,8 @@ $))]))}))) (throw (ex-info - (str "Can't produce Schema apidocs for " spesification) - {:type spesification, :coercion :schema})))) + (str "Can't produce Schema apidocs for " specification) + {:type specification, :coercion :schema})))) (-compile-model [_ model _] model) (-open-model [_ schema] (st/open-schema schema)) (-encode-error [_ error] diff --git a/modules/reitit-spec/src/reitit/coercion/spec.cljc b/modules/reitit-spec/src/reitit/coercion/spec.cljc index 72086a61..6d106187 100644 --- a/modules/reitit-spec/src/reitit/coercion/spec.cljc +++ b/modules/reitit-spec/src/reitit/coercion/spec.cljc @@ -91,8 +91,8 @@ (reify coercion/Coercion (-get-name [_] :spec) (-get-options [_] opts) - (-get-apidocs [this spesification {:keys [parameters responses]}] - (case spesification + (-get-apidocs [this specification {:keys [parameters responses]}] + (case specification :swagger (swagger/swagger-spec (merge (if parameters @@ -113,8 +113,8 @@ $))]))}))) (throw (ex-info - (str "Can't produce Spec apidocs for " spesification) - {:spesification spesification, :coercion :spec})))) + (str "Can't produce Spec apidocs for " specification) + {:specification specification, :coercion :spec})))) (-compile-model [_ model name] (into-spec model name)) (-open-model [_ spec] spec) diff --git a/perf-test/clj/reitit/bide_perf_test.clj b/perf-test/clj/reitit/bide_perf_test.clj index fa05247e..495b455b 100644 --- a/perf-test/clj/reitit/bide_perf_test.clj +++ b/perf-test/clj/reitit/bide_perf_test.clj @@ -207,39 +207,11 @@ (routing-test2) (reverse-routing-test)) -(import '[reitit Trie]) - -(set! *warn-on-reflection* true) (comment - (let [trie ] + (import '[reitit Trie]) + (set! *warn-on-reflection* true) - - (println - (Trie/lookup trie "/auth/login")) - - ;; 27ns - (cc/quick-bench - (dotimes [_ 1000] - (Trie/lookup trie "/auth/login"))) - - (println - (Trie/lookup trie "/auth/recovery/token/123")) - - ;; 82ns - (cc/quick-bench - (dotimes [_ 1000] - (Trie/lookup trie "/auth/recovery/token/123"))) - - (println - (Trie/lookup trie "/workspace/1/1")) - - ;; 96ns - (cc/quick-bench - (dotimes [_ 1000] - (Trie/lookup trie "/workspace/1/1"))))) - -(comment (let [trie (Trie/linearMatcher [(Trie/staticMatcher "/auth/" (Trie/linearMatcher