diff --git a/src/puppetlabs/puppetdb/pdb_routing.clj b/src/puppetlabs/puppetdb/pdb_routing.clj index d68667c2a0..6a2016a3f8 100644 --- a/src/puppetlabs/puppetdb/pdb_routing.clj +++ b/src/puppetlabs/puppetdb/pdb_routing.clj @@ -28,33 +28,20 @@ {:status 503 :body (tru "PuppetDB is currently down. Try again later.")}))) -(defn wrap-with-context [uri route] - (compojure/context uri [] route)) - -(defn pdb-core-routes [defaulted-config get-shared-globals enqueue-command-fn - query-fn clean-fn delete-node-fn] - (let [db-cfg #(select-keys (get-shared-globals) [:scf-read-db])] - (map #(apply wrap-with-context %) - (partition - 2 - ;; The remaining get-shared-globals args are for wrap-with-globals. - ["/" (fn [req] - (->> req - rreq/request-url - (format "%s/dashboard/index.html") - rr/redirect)) - "/dashboard" (dashboard/build-app dashboard/default-meter-defs) - "/meta" (meta/build-app db-cfg defaulted-config) - "/cmd" (cmd/command-app get-shared-globals - enqueue-command-fn - (conf/reject-large-commands? defaulted-config) - (conf/max-command-size defaulted-config)) - "/query" (server/build-app get-shared-globals) - "/admin" (admin/build-app enqueue-command-fn - query-fn - db-cfg - clean-fn - delete-node-fn)])))) +(defn pdb-core-routes + [defaulted-config get-shared-globals enqueue-command-fn query-fn clean-fn delete-node-fn] + (let [db-cfg #(select-keys (get-shared-globals) [:scf-read-db]) + context #(compojure/context %1 [] %2)] + [(compojure/GET "/" req + (rr/redirect (str (rreq/request-url req) "/dashboard/index.html"))) + (context "/dashboard" (dashboard/build-app dashboard/default-meter-defs)) + (context "/meta" (meta/build-app db-cfg defaulted-config)) + (context "/cmd" (cmd/command-app get-shared-globals enqueue-command-fn + (conf/reject-large-commands? defaulted-config) + (conf/max-command-size defaulted-config))) + (context "/query" (server/build-app get-shared-globals)) + (context "/admin" (admin/build-app enqueue-command-fn query-fn db-cfg clean-fn + delete-node-fn))])) (defn pdb-app [root maint-mode-fn app-routes] (compojure/context root []