-
-
Save ApophisLee/74918447fd2e93a3aeac42c1ce4503f1 to your computer and use it in GitHub Desktop.
Revisions
-
JalfResi revised this gist
Jul 16, 2021 . 1 changed file with 9 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -13,19 +13,19 @@ func main() { panic(err) } handler := func(p *httputil.ReverseProxy) func(http.ResponseWriter, *http.Request) { return func(w http.ResponseWriter, r *http.Request) { log.Println(r.URL) r.Host = remote.Host w.Header().Set("X-Ben", "Rad") p.ServeHTTP(w, r) } } proxy := httputil.NewSingleHostReverseProxy(remote) http.HandleFunc("/", handler(proxy)) err = http.ListenAndServe(":8080", nil) if err != nil { panic(err) } } -
JalfResi revised this gist
Jun 23, 2021 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -24,6 +24,7 @@ func main() { func handler(p *httputil.ReverseProxy) func(http.ResponseWriter, *http.Request) { return func(w http.ResponseWriter, r *http.Request) { log.Println(r.URL) r.Host = remote.Host w.Header().Set("X-Ben", "Rad") p.ServeHTTP(w, r) } -
JalfResi created this gist
Aug 20, 2013 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ package main import( "log" "net/url" "net/http" "net/http/httputil" ) func main() { remote, err := url.Parse("http://google.com") if err != nil { panic(err) } proxy := httputil.NewSingleHostReverseProxy(remote) http.HandleFunc("/", handler(proxy)) err = http.ListenAndServe(":8080", nil) if err != nil { panic(err) } } func handler(p *httputil.ReverseProxy) func(http.ResponseWriter, *http.Request) { return func(w http.ResponseWriter, r *http.Request) { log.Println(r.URL) w.Header().Set("X-Ben", "Rad") p.ServeHTTP(w, r) } }