Fix fetch example

This commit is contained in:
aki-0421 2023-05-28 13:06:16 +09:00
parent ed546fec09
commit fcca3fd39a
No known key found for this signature in database
GPG Key ID: 64A8CF6D437D166A
2 changed files with 2 additions and 2 deletions

View File

@ -32,7 +32,7 @@ func handler(w http.ResponseWriter, req *http.Request) {
// responds with origin server // responds with origin server
fc := fetch.NewClient() fc := fetch.NewClient()
proxy := httputil.ReverseProxy{ proxy := httputil.ReverseProxy{
Transport: fc.HTTPClient().Transport, Transport: fc.HTTPClient(fetch.RedirectModeManual).Transport,
Director: func(r *http.Request) { Director: func(r *http.Request) {
r.URL = req.URL r.URL = req.URL
}, },

View File

@ -21,7 +21,7 @@ func main() {
} }
r.Header.Set("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/111.0") r.Header.Set("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/111.0")
res, err := cli.Do(r) res, err := cli.Do(r, nil)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
w.WriteHeader(http.StatusInternalServerError) w.WriteHeader(http.StatusInternalServerError)