 (ns replme.web.repl
-  (:require [clojure.core.async :refer [go <! >! <!! >!! chan close! go-loop]]
+  (:require [clojure.core.async :refer [go <! >! <!! >!! chan close! go-loop filter<]]
             [org.httpkit.server :refer [send! with-channel on-receive on-close open? websocket?]]
             [http.async.client :as http]
             [clojure.tools.logging :as log]

    (when (open? channel)
      (recur (<! out-chan)))))

(defn open-websocket
  [docker-client req repo]
  (let [in-chan (chan)
        out-chan (chan)]
    (with-channel req channel
      (if (websocket? channel)
        (let [[docker-id http-client] (docker-repl docker-client repo in-chan out-chan)

(defn- docker-attach
  [client id]
  (let [output (chan)
        url (str "http://" (:host client) "/containers/" id "/logs?stdout=1&follow=1") http-client (http/create-client)]
    (go
      (log/info "Reading logs from: " url)
      (doseq [msg (http/string (http/stream-seq http-client :get url))]
