Skip to content

Instantly share code, notes, and snippets.

@lukaszkorecki
Created May 22, 2017 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukaszkorecki/2d020f14ceeecf78efb93eb147411960 to your computer and use it in GitHub Desktop.
Save lukaszkorecki/2d020f14ceeecf78efb93eb147411960 to your computer and use it in GitHub Desktop.
(require '[aleph.http :as http])
(require '[ring.middleware.cookies :as cookies])
;; serv is a component which wraps aleph.http.server creation/teardown
(def ECHO (component/start (serv/create "ECHO" {:port 3037
:handler (fn [req]
(log/info req)
{:status 200 :body "ok" })})))
;; (component/stop ECHO)
(def PROXY (component/start (serv/create "PROXY"
{:port 3000
:handler (fn [req]
(log/infof "REQ to proxy %s" req)
(http/request {:method (:request-method req)
:url (str "http://localhost:3037" (:uri req))
:headers (dissoc (:headers req) "host" "content-length")
:follow-redirects true
:throw-exceptions false}))})))
;; (component/stop PROXY)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment