      (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]

    {:type :counter
     :value (counters/value c)}))

;;
;; Implementation
;;

(defn- ensure-leading-slash [s]
  (if (not= \/ (first s))
    (str \/ s)
