Skip to content

Instantly share code, notes, and snippets.

@giter
Created August 19, 2014 15:13
Show Gist options
  • Save giter/4d517931fbc9d172fe03 to your computer and use it in GitHub Desktop.
Save giter/4d517931fbc9d172fe03 to your computer and use it in GitHub Desktop.
package main
import (
"bufio"
"net/http"
"log"
)
func handler(w http.ResponseWriter, r *http.Request) {
resp, err := http.DefaultTransport.RoundTrip(r)
if err != nil {
log.Print(err)
return
}
for k, vv := range resp.Header {
for _,v := range vv{
w.Header().Add(k,v)
}
}
w.Header().Add("Proxy","HIT")
if resp.StatusCode >= 300 {
w.WriteHeader(resp.StatusCode);
return
}
defer resp.Body.Close()
bufio.NewReader(resp.Body).WriteTo(w)
}
func main() {
http.HandleFunc("/", handler)
log.Println("Start serving on port 8888")
http.ListenAndServe(":8888", nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment