Created
October 6, 2011 09:50
-
-
Save skuro/1266998 to your computer and use it in GitHub Desktop.
stunnr.core.clj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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