I'm having a weird issue with (reverse) proxying api requests to the github
api. I'm simply trying to log each request/response pair in a roundtripper,
but in the example below I left it out because that logic doesn't seem to
be the issue here:
package main
import (
"log"
"net/http"
"net/http/httputil"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
director := func(req *http.Request) {
req = r
req.URL.Scheme = "https"
req.URL.Host = "api.github.com"
log.Println(req.Method, req.URL.String())
log.Println(req.UserAgent())
}
proxy := &httputil.ReverseProxy{Director: director}
proxy.ServeHTTP(w, r)
})
log.Fatal(http.ListenAndServe(":8181", nil))
}
When I now issue a curl request to the proxy:
curl http://localhost:8181/orgs/docker
I receive a "We had issues producing the response to your request." from
Github, no json whatsoever. When I issue the curl command against github
directly it works withoug issue, i.e:
curl https://api.github.com/orgs/docker
{...}
I'm probably missing something obvious, anyone has a clue?
Thanks in advance!
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.