11 "go.stargrave.org/godlighty"
15 host := "some-proxied-host.com"
16 godlighty.Hosts[host] = &godlighty.HostCfg{
17 Hooks: []godlighty.Hook{
18 func(w http.ResponseWriter, r *http.Request) bool {
20 if r.URL, err = url.ParseRequestURI(r.RequestURI); err != nil {
24 r.URL.Host = "[dead::beaf]"
26 resp, err := http.DefaultClient.Do(r)
28 fmt.Printf("%s %s \"%s %+q %s\" %d \"%s\" \"%s\"\n",
29 r.RemoteAddr, host, r.Method, godlighty.PathWithQuery(r.URL),
30 r.Proto, http.StatusBadGateway, err.Error(),
31 r.Header.Get("User-Agent"),
33 http.Error(w, err.Error(), http.StatusBadGateway)
36 for k, vs := range resp.Header {
37 for _, v := range vs {
41 w.WriteHeader(resp.StatusCode)
42 size, _ := io.Copy(w, resp.Body)
44 fmt.Printf("%s %s \"%s %+q %s\" %d %d \"%s\"\n",
45 r.RemoteAddr, host, r.Method, godlighty.PathWithQuery(r.URL),
46 r.Proto, resp.StatusCode, size,
47 r.Header.Get("User-Agent"),