 (ns akvo.lumen.component.handler
-  (:require [compojure.core :as compojure.core]
-            [compojure.response :as compojure.res]
+  (:require [compojure.response :as compojure.res]
             [integrant.core :as ig]
             [clojure.tools.logging :as log]
             [akvo.lumen.specs.components :refer [integrant-key]]

    (let [
          routes  (->> endpoints
                       (reduce-kv (fn [c k v]
                                    (conj c [k v])
                                    ) [] ))

;;          _ (log/warn routes)

          handler (ring/ring-handler
                   (ring/router routes
                                {:data {;; :coercion reitit.coercion.spec/coercion
                                        ;;:muuntaja m/instance
                                        :middleware middleware}
                                 :conflicts (constantly nil)}))
;;          _ (log/error :handler handler)
]
      (assoc opts :handler handler))
    opts))


(s/def ::endpoints (s/coll-of fn?
                              ;;:count 24

        (if (vector? res)
          (commons/variant->response res request)
          res)))))
