             [org.httpkit.timer :refer [schedule-task]]))
 
 (def channel-hub (atom {}))
+
+(defn handle-cors []
+  {:status 204
+   :headers {"Access-Control-Allow-Origin" "*"
+             "Connection" "close"}})
 
 (defn handle-404 []
   {:status 404

(defn handle-connections []
  {:status 200
   :headers {"Content-Type" "text/plain"
             "Cache-Control" "no-cache"
             "Connection" "close"}
   :body (str (count @channel-hub))})

                        (swap! channel-hub dissoc channel)))))

(defn app [req]
  (if (= (:request-method req) :options)
    (handle-cors)
    (case (:uri req)
      "/connections" (handle-connections)
      "/sse" (handle-sse req)
      (handle-404))))

(defn notify-channels []
  (let [time (System/currentTimeMillis)]
