 
 (defn- body->links
   [string options]
-  (prn options)
   (-> string
       (java.io.StringReader.)
       enlive/html-resource

            distinct
            (remove invalid-link?))))))

(defn- stream-links*
  "Sends 3 different sse events (message, results, end-message) depending on
what part of the page it's updating."
  [send-event-fn sse-context url options]
  (let [send-to (partial send-event-fn sse-context)]
    (if-let [links (url->links url options)]
      (do
        (send-to "message"
                 (format "%s has %s links. Fetching data... <img src='/images/spinner.gif' />"
                         url (count links)))
        (let [start-time (System/currentTimeMillis)
              link-results (doall (pmap (partial fetch-link-and-send-row send-to url) links))]
          (send-final-message send-to (calc-time start-time) link-results))
        (send-to "end-message" (str "result?url=" url
                                    (if (seq (:selector options))
                                      (str "&selector=" (:selector options)) ""))))
      (send-to "error" "Unable to fetch the given url."))))

(defn stream-links
  "Streams a url's verified links with a given fn and sse-context."

    (try
      (stream-links* send-event-fn sse-context url options)
      {:status 200}
      (catch Exception exception
        (log/error :msg (str "Unexpected error: " exception))
        (send-event-fn sse-context "error" "An unexpected error occurred. :(")))
    (log/error :msg "No url given to verify links. Ignored.")))