Skip to content

Instantly share code, notes, and snippets.

@skuro
Created October 6, 2011 09:50
Show Gist options
  • Save skuro/1266998 to your computer and use it in GitHub Desktop.
Save skuro/1266998 to your computer and use it in GitHub Desktop.
stunnr.core.clj
(ns stunnr.core
(:require [http.async.client :as c]
[http.async.client.request :as r]))
(def results (atom []))
(def requests (atom []))
(defn fetch-url [^String url]
(swap! requests conj (future
(with-open [client (c/create-client)]
(let [req (r/prepare-request client
:get "http://google.com")
res (r/execute-request req {:completed (fn [res]
(clojure.pprint/pprint res)
(swap! results conj res))})]
;; now you have request, next thing to do would be to execute it
(c/await res))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment