This commit is contained in:
Ubuntu
2012-12-31 04:22:07 +00:00
parent 92623001b5
commit 0b01415b76

View File

@@ -44,7 +44,9 @@ func main() {
r.HandleFunc("/", ProxyFunc)
http.Handle("/", r)
log.Fatal(http.ListenAndServe(":8080", nil))
port := 80
fmt.Println("listening and serving on port", port)
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%v", port), nil))
}
func ProxyFunc(w http.ResponseWriter, req *http.Request) {
@@ -63,6 +65,7 @@ func ProxyFunc(w http.ResponseWriter, req *http.Request) {
if err != nil {
panic(err)
}
fmt.Println("proxying to", destUrl)
proxy := httputil.NewSingleHostReverseProxy(destUrl)
proxy.ServeHTTP(w, req)
// todo: how to handle destination failures. I got this in log output when testing a bad endpoint: