Skip to content

Instantly share code, notes, and snippets.

@scorredoira
Created May 23, 2020 20:34
Show Gist options
  • Save scorredoira/da7b43091f88aa8371b0b03b9bc4b3cc to your computer and use it in GitHub Desktop.
Save scorredoira/da7b43091f88aa8371b0b03b9bc4b3cc to your computer and use it in GitHub Desktop.
import "stdlib/native"
export function main() {
let url = http.parseURL("http://example.com/")
let proxy = httputil.newSingleHostReverseProxy(url)
let server = http.newServer()
server.address = ":9999"
server.handler = (w, r) => {
r.url.host = url.host
r.url.scheme = url.scheme
r.host = url.host
proxy.serveHTTP(w, r)
}
server.start()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment