    [yada.core :refer (make-async-handler)]
    [hiccup.core :refer (html h) :rename {h escape-html}]
    [markdown.core :as markdown]
-   [com.stuartsierra.component :refer (using)]
+   [com.stuartsierra.component :refer (using Lifecycle)]
    [tangrammer.component.co-dependency :refer (co-using)]
    [ring.mock.request :refer (request) :rename {request mock-request}]))
 

   :headers {"content-type" "text/html;charset=utf-8"}
   :body body})

(defrecord ExamplesService [router handlers]
  RouteProvider
  (routes [this]
    ["/examples"
     [["/"
       (vec
        (concat
         (for [h handlers]
           [(get-path h) (handler (keyword (basename h))
                                  (make-async-handler (eval (resource-map h))))])
         [["index.html"
           (handler
            ::index
            (fn [_]
              (ok
               (index (:routes @router) handlers))))]
          ["tests.html"
           (handler
            ::tests
            (fn [_]
              (ok (tests (:routes @router) handlers))))
           ]
          ["" (redirect ::index)]]))]
      ["" (redirect ::index)]]]))

(defn new-examples-service [& {:as opts}]
  (-> (->> opts
           (merge {:handlers
                   [(->BodyAsString)
                    (->StatusAndHeaders)
                    (->DynamicBody)
                    (->AsyncBody)


;; Conditional GETs

(defrecord ConditionalGet [start-time]
  Example
  (resource-map [_] {:body "Hello World!"
                     :resource {:last-modified start-time}
                     })
  (request [_] {:method :get
                :headers {"Accept" "text/plain"}})
  (expected-response [_] {:status 200}))
