diff --git a/modules/reitit-http/src/reitit/http.cljc b/modules/reitit-http/src/reitit/http.cljc index 0f935966..e4a9a6ca 100644 --- a/modules/reitit-http/src/reitit/http.cljc +++ b/modules/reitit-http/src/reitit/http.cljc @@ -16,7 +16,7 @@ (defn compile-result [[path data] {:keys [::default-options-handler] :as opts}] (let [[top childs] (ring/group-keys data) childs (cond-> childs - (and (not (:options childs)) default-options-handler) + (and (not (:options childs)) (not (:handler top)) default-options-handler) (assoc :options {:no-doc true, :handler default-options-handler})) compile (fn [[path data] opts scope] (interceptor/compile-result [path data] opts scope)) diff --git a/modules/reitit-ring/src/reitit/ring.cljc b/modules/reitit-ring/src/reitit/ring.cljc index 104e6a7d..0915151a 100644 --- a/modules/reitit-ring/src/reitit/ring.cljc +++ b/modules/reitit-ring/src/reitit/ring.cljc @@ -31,7 +31,7 @@ (defn compile-result [[path data] {:keys [::default-options-handler] :as opts}] (let [[top childs] (group-keys data) childs (cond-> childs - (and (not (:options childs)) default-options-handler) + (and (not (:options childs)) (not (:handler top)) default-options-handler) (assoc :options {:no-doc true, :handler default-options-handler})) ->endpoint (fn [p d m s] (-> (middleware/compile-result [p d] opts s) diff --git a/modules/reitit-ring/src/reitit/ring/spec.cljc b/modules/reitit-ring/src/reitit/ring/spec.cljc index 487a2211..e1af34c3 100644 --- a/modules/reitit-ring/src/reitit/ring/spec.cljc +++ b/modules/reitit-ring/src/reitit/ring/spec.cljc @@ -20,14 +20,8 @@ (s/def ::patch map?) -(s/def ::endpoint - (s/keys :req-un [::rs/handler] - :opt-un [::rs/name ::rs/no-doc ::middleware])) - (s/def ::data - (s/merge - ::endpoint - (s/map-of #{:get :head :post :put :delete :connect :options :trace :patch} map?))) + (s/keys :opt-un [::rs/handler ::rs/name ::rs/no-doc ::middleware])) ;; ;; Validator diff --git a/test/clj/reitit/http_test.clj b/test/clj/reitit/http_test.clj index f18bdf36..934ef9bc 100644 --- a/test/clj/reitit/http_test.clj +++ b/test/clj/reitit/http_test.clj @@ -495,11 +495,11 @@ (fn [{:keys [::r/router]}] (is router)) {:executor sieppari/executor}) - {})) + {})) (testing "3-arity" ((http/ring-handler (http/router []) (fn [{:keys [::r/router]}] (is router)) {:executor sieppari/executor}) - {} ::respond ::raise))) + {} ::respond ::raise))) diff --git a/test/cljc/reitit/ring_spec_test.cljc b/test/cljc/reitit/ring_spec_test.cljc index ae99764d..6e2d7c6d 100644 --- a/test/cljc/reitit/ring_spec_test.cljc +++ b/test/cljc/reitit/ring_spec_test.cljc @@ -21,13 +21,13 @@ (testing "with default spec validates :name, :handler and :middleware" (is (thrown-with-msg? ExceptionInfo - #":reitit.ring.spec/invalid-route-data" + #"Invalid route data" (ring/router ["/api" {:handler "identity"}] {:validate rrs/validate}))) (is (thrown-with-msg? ExceptionInfo - #":reitit.ring.spec/invalid-route-data" + #"Invalid route data" (ring/router ["/api" {:handler identity :name "kikka"}] @@ -36,7 +36,7 @@ (testing "all endpoints are validated" (is (thrown-with-msg? ExceptionInfo - #":reitit.ring.spec/invalid-route-data" + #"Invalid route data" (ring/router ["/api" {:patch {:handler "identity"}}] {:validate rrs/validate})))) @@ -69,7 +69,7 @@ (handler request)))}]}}))) (is (thrown-with-msg? ExceptionInfo - #":reitit.ring.spec/invalid-route-data" + #"Invalid route data" (ring/router ["/api" {:get {:handler identity :roles #{:adminz}}}] @@ -113,7 +113,7 @@ (is (thrown-with-msg? ExceptionInfo - #":reitit.ring.spec/invalid-route-data" + #"Invalid route data" (ring/router ["/api" ["/plus/:e" diff --git a/test/cljc/reitit/ring_test.cljc b/test/cljc/reitit/ring_test.cljc index bce7314d..b23d41b7 100644 --- a/test/cljc/reitit/ring_test.cljc +++ b/test/cljc/reitit/ring_test.cljc @@ -570,10 +570,10 @@ (ring/router []) (fn [{:keys [::r/router]}] (is router))) - {})) + {})) (testing "3-arity" ((ring/ring-handler (ring/router []) (fn [{:keys [::r/router]} _ _] (is router))) - {} ::respond ::raise))) + {} ::respond ::raise)))