 
 (run (route {:get
              {"/foo" {"/bing" bing}
+              "/slow-thing"
               "/" home}}))

           (java.io IOException))
  (:require [clojure.core.async :as async :refer [go go-loop >! <! <!! >!! chan]]
            [clojure.string :as string :refer [join split]]))

;; concept...
;; every view gets an in-port and an out-port
;; they can be socket ports, in which case you push bytes onto them
;; or they can be HTTP ports, in which case you push content onto them
;; you can also use symbols to push other stuff
;; like: (go (>! out-port {:headers {:content-type "text/html" :status 200}}))
;;       (go (>! out-port "<html></html">))
;;       (go (>! out-port :close))

(def *buffer* (ByteBuffer/allocate 16384)) ;; 16k...


(defn route [mappings]
  "TODO: add regex support, too, cuz we should."
  (let [route** (fn route* [mappings full-path path in-chan out-chan]
                  (loop [prefixes (sort (fn [x] (count (str x))) > (keys mappings))]
                    (if (empty? prefixes)
                      (go (>! out-chan 404)
                          (>! out-chan :end))
