Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nasa9084/go-logtransport
http.RoundTripper which logs request/response
https://github.com/nasa9084/go-logtransport
Last synced: 11 days ago
JSON representation
http.RoundTripper which logs request/response
- Host: GitHub
- URL: https://github.com/nasa9084/go-logtransport
- Owner: nasa9084
- License: mit
- Created: 2019-10-31T06:11:50.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-08-28T14:03:44.000Z (about 4 years ago)
- Last Synced: 2024-10-06T00:41:07.046Z (about 1 month ago)
- Language: Go
- Homepage:
- Size: 4.88 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
logtransport
===[![GoDoc](https://godoc.org/github.com/nasa9084/go-logtransport?status.svg)](https://godoc.org/github.com/nasa9084/go-logtransport)
logtransport is a thin wrapper of http.RoundTripper interface, which logs request and response using given logger.
## SYNOPSIS
``` go
func 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)
}```
or if you do not need to customize HTTP transport, just import `overwrite` subpackage with blank identifier:
``` go
import _ "github.com/nasa9084/go-logtransport/overwrite"
```