diff --git a/advanced/composing_routers.html b/advanced/composing_routers.html index 57e0fdf9..60bdf37c 100644 --- a/advanced/composing_routers.html +++ b/advanced/composing_routers.html @@ -1150,7 +1150,7 @@ diff --git a/advanced/configuring_routers.html b/advanced/configuring_routers.html index bc61c33e..1f79dec4 100644 --- a/advanced/configuring_routers.html +++ b/advanced/configuring_routers.html @@ -805,7 +805,11 @@ :conflicts -Function of {route #{route}} => () to handle conflicting routes (default reitit.core/throw-on-conflicts!) +Function of {route #{route}} => () to handle conflicting routes + + +:exception +Function of Exception => Exception to handle creation time exceptions (default reitit.exception/exception) :router @@ -856,7 +860,7 @@ diff --git a/advanced/dev_workflow.html b/advanced/dev_workflow.html index 464c1d2f..550bf08a 100644 --- a/advanced/dev_workflow.html +++ b/advanced/dev_workflow.html @@ -915,7 +915,7 @@ diff --git a/advanced/different_routers.html b/advanced/different_routers.html index af1814b8..856a3f58 100644 --- a/advanced/different_routers.html +++ b/advanced/different_routers.html @@ -863,7 +863,7 @@ diff --git a/advanced/route_validation.html b/advanced/route_validation.html index 310f79c2..ddb4eb1e 100644 --- a/advanced/route_validation.html +++ b/advanced/route_validation.html @@ -951,7 +951,7 @@ diff --git a/advanced/shared_routes.html b/advanced/shared_routes.html index a4c3c801..20dbe65f 100644 --- a/advanced/shared_routes.html +++ b/advanced/shared_routes.html @@ -871,7 +871,7 @@ diff --git a/basics/name_based_routing.html b/basics/name_based_routing.html index 37e6b3bc..2e49d49a 100644 --- a/basics/name_based_routing.html +++ b/basics/name_based_routing.html @@ -874,7 +874,7 @@ diff --git a/basics/path_based_routing.html b/basics/path_based_routing.html index c6149419..c2d204a4 100644 --- a/basics/path_based_routing.html +++ b/basics/path_based_routing.html @@ -832,7 +832,7 @@ diff --git a/basics/route_conflicts.html b/basics/route_conflicts.html index 174f9130..fc48bd0f 100644 --- a/basics/route_conflicts.html +++ b/basics/route_conflicts.html @@ -875,7 +875,7 @@ diff --git a/basics/route_data.html b/basics/route_data.html index 0e409014..4e96c087 100644 --- a/basics/route_data.html +++ b/basics/route_data.html @@ -926,7 +926,7 @@ diff --git a/basics/route_data_validation.html b/basics/route_data_validation.html index 55ccbcc2..caae3f7d 100644 --- a/basics/route_data_validation.html +++ b/basics/route_data_validation.html @@ -766,7 +766,7 @@

To fail fast, we could use the custom :coerce and :compile hooks to apply data validation and throw exceptions on first sighted problem.

But there is a better way. Router has a :validation hook to validate the whole route tree after it's successfuly compiled. It expects a 2-arity function routes opts => () that can side-effect in case of validation errors.

clojure.spec

-

Namespace reitit.spec contains specs for main parts of reitit.core and a helper function validate-spec! that runs spec validation for all route data and throws an exception if any errors are found.

+

Namespace reitit.spec contains specs for main parts of reitit.core and a helper function validate that runs spec validation for all route data and throws an exception if any errors are found.

A Router with invalid route data:

(require '[reitit.core :as r])
 
@@ -779,7 +779,7 @@
 
 (r/router
   ["/api" {:handler "identity"}]
-  {:validate rs/validate-spec!})
+  {:validate rs/validate})
 ; CompilerException clojure.lang.ExceptionInfo: Invalid route data:
 ;
 ; -- On route -----------------------
@@ -791,7 +791,7 @@
 ; {:problems (#reitit.spec.Problem{:path "/api", :scope nil, :data {:handler "identity"}, :spec :reitit.spec/default-data, :problems #:clojure.spec.alpha{:problems ({:path [:handler], :pred clojure.core/fn?, :val "identity", :via [:reitit.spec/default-data :reitit.spec/handler], :in [:handler]}), :spec :reitit.spec/default-data, :value {:handler "identity"}}})}, compiling: ...
 

Customizing spec validation

-

rs/validate-spec! reads the following router options:

+

rs/validate reads the following router options:

@@ -822,7 +822,7 @@ ["/api" {:handler identity ::roles #{:adminz}}] {::rs/explain e/expound-str - :validate rs/validate-spec!}) + :validate rs/validate}) ; CompilerException clojure.lang.ExceptionInfo: Invalid route data:;; -- On route ----------------------- @@ -857,7 +857,7 @@ ["/api" {:handler identity}] {:spec (s/merge (s/keys:req [::roles]) ::rs/default-data) ::rs/explain e/expound-str - :validate rs/validate-spec!}) + :validate rs/validate}) ; CompilerException clojure.lang.ExceptionInfo: Invalid route data:;; -- On route ----------------------- @@ -925,7 +925,7 @@ diff --git a/basics/route_syntax.html b/basics/route_syntax.html index ab19d740..7e953d13 100644 --- a/basics/route_syntax.html +++ b/basics/route_syntax.html @@ -885,7 +885,7 @@ diff --git a/basics/router.html b/basics/router.html index fdd5d907..997b4039 100644 --- a/basics/router.html +++ b/basics/router.html @@ -886,7 +886,7 @@ diff --git a/coercion/clojure_spec_coercion.html b/coercion/clojure_spec_coercion.html index b29a0e11..666942ef 100644 --- a/coercion/clojure_spec_coercion.html +++ b/coercion/clojure_spec_coercion.html @@ -897,7 +897,7 @@ diff --git a/coercion/coercion.html b/coercion/coercion.html index a1669aca..ae440220 100644 --- a/coercion/coercion.html +++ b/coercion/coercion.html @@ -939,7 +939,7 @@ diff --git a/coercion/data_spec_coercion.html b/coercion/data_spec_coercion.html index 7bd6fa79..6bd8c342 100644 --- a/coercion/data_spec_coercion.html +++ b/coercion/data_spec_coercion.html @@ -838,7 +838,7 @@ diff --git a/coercion/schema_coercion.html b/coercion/schema_coercion.html index ca53444c..2554776e 100644 --- a/coercion/schema_coercion.html +++ b/coercion/schema_coercion.html @@ -839,7 +839,7 @@ diff --git a/development.html b/development.html index 486706ce..2ed5b629 100644 --- a/development.html +++ b/development.html @@ -829,7 +829,7 @@ lein test diff --git a/faq.html b/faq.html index 5f855aa1..9d093c10 100644 --- a/faq.html +++ b/faq.html @@ -907,7 +907,7 @@ diff --git a/frontend/basics.html b/frontend/basics.html index 4d5b6296..4278dda0 100644 --- a/frontend/basics.html +++ b/frontend/basics.html @@ -827,7 +827,7 @@ React breaking due to errors.

diff --git a/frontend/browser.html b/frontend/browser.html index c5d7b21f..143793ae 100644 --- a/frontend/browser.html +++ b/frontend/browser.html @@ -823,7 +823,7 @@ event handler for page change events.

diff --git a/frontend/controllers.html b/frontend/controllers.html index 265a6380..3a3f53cc 100644 --- a/frontend/controllers.html +++ b/frontend/controllers.html @@ -907,7 +907,7 @@ missing resources.

diff --git a/http/default_interceptors.html b/http/default_interceptors.html index bce8866b..e143449d 100644 --- a/http/default_interceptors.html +++ b/http/default_interceptors.html @@ -829,7 +829,7 @@ diff --git a/http/interceptors.html b/http/interceptors.html index 45ba9671..57bd414e 100644 --- a/http/interceptors.html +++ b/http/interceptors.html @@ -857,7 +857,7 @@ diff --git a/http/pedestal.html b/http/pedestal.html index 37b4d996..b0ecb293 100644 --- a/http/pedestal.html +++ b/http/pedestal.html @@ -868,7 +868,7 @@ diff --git a/http/sieppari.html b/http/sieppari.html index 19669cd6..cb3451ad 100644 --- a/http/sieppari.html +++ b/http/sieppari.html @@ -869,7 +869,7 @@ diff --git a/http/transforming_interceptor_chain.html b/http/transforming_interceptor_chain.html index d5a29a56..eee54d63 100644 --- a/http/transforming_interceptor_chain.html +++ b/http/transforming_interceptor_chain.html @@ -868,7 +868,7 @@ diff --git a/index.html b/index.html index 9de5033a..012a6be5 100644 --- a/index.html +++ b/index.html @@ -772,6 +772,7 @@
  • Modular
  • Fast
  • +

    There is #reitit in Clojurians Slack for discussion & help.

    Main Modules

    Extra modules