Skip to content

Instantly share code, notes, and snippets.

@hiredman
Created August 13, 2015 23:03
Show Gist options
  • Save hiredman/1036fbee8067d33aa0b4 to your computer and use it in GitHub Desktop.
Save hiredman/1036fbee8067d33aa0b4 to your computer and use it in GitHub Desktop.
aleph-proxy.clj
(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