Created
October 9, 2015 01:09
-
-
Save oinume/52febbab0734a8c27038 to your computer and use it in GitHub Desktop.
http.RoundTripper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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