Documentation ¶
Overview ¶
Package logtransport implements a http.RoundTripper which logs request before the request is sent and response after the request.
Example ¶
handler := func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) w.Write([]byte("Hello, world!")) } srv := httptest.NewServer(http.HandlerFunc(handler)) defer srv.Close() c := &http.Client{ Transport: &logtransport.Transport{ // you can use other logger like sirupsen/logrus Logger: log.New(os.Stdout, "", log.LstdFlags), }, } c.Get(srv.URL)
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Printer ¶
type Printer interface {
Print(args ...interface{})
}
Logger is an interface of a logger, which is used for logging outgoing HTTP request and incoming HTTP response.
type Transport ¶
type Transport struct { Transport http.RoundTripper Logger Printer }
Transport is a wrapper of http.RoundTripper.
Click to show internal directories.
Click to hide internal directories.