      (let [request-uri (:uri request)]
        (if (or (.startsWith request-uri (sanitize-uri uri))
                (= request-uri uri))
-         (metrics-json request)
+         (serve-metrics request)
          (handler request))))))

  [metric-name (render-to-basic metric)])


; Exposing --------------------------------------------------------------------
(defn- metrics-json [request]
  (let [metrics-map (into {} (map render-metric (all-metrics)))
        json (generate-string metrics-map)]
    (-> (response json)
      (header "Content-Type" "application/json"))))

(defn expose-metrics-as-json
  ([handler]

            [metrics.counters :as counters]
            [metrics.timers :as timers]
            [ring.util.response :refer [header response]]
            [metrics.core :refer [default-registry]]
            [metrics.utils :refer [all-metrics]]
            [cheshire.core :refer [generate-string]]))

