https://github.com/ciricc/httpaddtransport
Global custom parameters for Go http client requests
https://github.com/ciricc/httpaddtransport
go http transport
Last synced: about 1 year ago
JSON representation
Global custom parameters for Go http client requests
- Host: GitHub
- URL: https://github.com/ciricc/httpaddtransport
- Owner: ciricc
- Created: 2022-11-04T21:46:45.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-11-04T21:52:24.000Z (over 3 years ago)
- Last Synced: 2025-02-09T20:16:48.503Z (about 1 year ago)
- Topics: go, http, transport
- Language: Go
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Utilite for logging and add default custom http headers into http client
This simple example shows how you can add default header for http client and setup log into default logger.
```go
package main
import (
"github.com/ciricc/httpaddtransport"
"http"
)
func main() {
httpAddTransport, err := httpaddtransport.New(nil, nil)
if err != nil {
panic(err)
}
httpAddTransport.Headers.Set("User-Agent", "go/1.19")
httpAddTransport.Log = true
httpClient := http.Client{
Transport: httpAddTransport
}
_, err = httpClient.Get("https://google.com/")
if err != nil {
panic(err)
}
}
```