oneandone-billing-mailer/pkg/mssa/http/connection_helper.go

31 lines
620 B
Go
Raw Permalink Normal View History

2022-08-17 01:34:18 +00:00
package mssahttp
import (
"net/http"
"time"
"git.icedream.tech/icedream/oneandone-billing-mailer/pkg/environment"
)
const (
connection_timeout = 30 * time.Second
)
type uaSetterTransport struct{}
func (t *uaSetterTransport) RoundTrip(req *http.Request) (*http.Response, error) {
actualReq := new(http.Request)
*actualReq = *req
actualReq.Header.Set("User-agent", environment.UserAgent())
return http.DefaultTransport.RoundTrip(actualReq)
}
var defaultClient = &http.Client{
Timeout: connection_timeout,
Transport: &uaSetterTransport{},
}
func GetDefaultClient() *http.Client {
return defaultClient
}