Skip to content

Instantly share code, notes, and snippets.

@oinume
Created October 9, 2015 01:09
Show Gist options
  • Save oinume/52febbab0734a8c27038 to your computer and use it in GitHub Desktop.
Save oinume/52febbab0734a8c27038 to your computer and use it in GitHub Desktop.
http.RoundTripper
package main
import (
"fmt"
"net/http"
)
type transport struct {
r http.RoundTripper
}
func (t transport) RoundTrip(req *http.Request) (*http.Response, error) {
resp, err := t.r.RoundTrip(req)
defer resp.Body.Close()
fmt.Printf("%v %v %v\n", req.Method, req.URL, resp.StatusCode)
return resp, err
}
func main() {
client := http.Client{}
http.DefaultTransport = transport{r: http.DefaultTransport}
client.Get("https://www.amebaownd.com")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment