Created
August 13, 2015 23:03
-
-
Save hiredman/1036fbee8067d33aa0b4 to your computer and use it in GitHub Desktop.
aleph-proxy.clj
This file contains 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
(require '[aleph.http :as http]) | |
(def main-server | |
(http/start-server | |
(constantly {:status 200 :body "yo"}) | |
{:host "localhost" | |
:port 3467})) | |
(def proxy-server | |
(http/start-server | |
(fn [req] | |
(http/request {:method (:request-method req) | |
:url (str "http://localhost:3467" (:uri req)) | |
:headers (dissoc (:headers req) "host" "content-length") | |
:follow-redirects true | |
:throw-exceptions false})) | |
{:host "localhost" | |
:port 3468})) | |
(while (with-open [s (:body (deref (http/get "http://localhost:3468/foo")))] | |
(= (slurp s) "yo"))) | |
(System/exit -1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment