diff --git a/modules/reitit-http/src/reitit/http.cljc b/modules/reitit-http/src/reitit/http.cljc index b60385558..db4158b01 100644 --- a/modules/reitit-http/src/reitit/http.cljc +++ b/modules/reitit-http/src/reitit/http.cljc @@ -133,7 +133,7 @@ (interceptor/queue executor)) router-opts (-> (r/options router) (assoc ::interceptor/queue (partial interceptor/queue executor)) - (dissoc :data) ; data is already merged into routes + (dissoc :data :path) ; data and path already take effect in routes (cond-> (seq interceptors) (update-in [:data :interceptors] (partial into (vec interceptors))))) router (reitit.http/router (r/routes router) router-opts) ;; will re-compile the interceptors diff --git a/test/clj/reitit/http_test.clj b/test/clj/reitit/http_test.clj index 0894ab9ac..c373a7afd 100644 --- a/test/clj/reitit/http_test.clj +++ b/test/clj/reitit/http_test.clj @@ -88,7 +88,24 @@ (testing "all named routes can be matched" (doseq [name (r/route-names router)] - (is (= name (-> (r/match-by-name router name) :data :name)))))))) + (is (= name (-> (r/match-by-name router name) :data :name))))))) + + (testing "path prefixed routes" + (let [router (http/router + [["/all" {:handler handler}] + ["/get" {:get {:handler handler}}] + ["/users" {:get handler}]] + {:path "/api"}) + app (http/ring-handler router nil {:executor sieppari/executor})] + + (testing "router can be extracted" + (is (= (r/routes router) + (r/routes (http/get-router app))))) + + (testing "handler resolved original router routes" + (doseq [router-path (mapv first (r/routes router))] + (is (= 200 + (:status (app {:uri router-path :request-method :get}))))))))) (def enforce-roles-interceptor {:enter (fn [{{::keys [roles] :as request} :request :as ctx}]