Skip to content

Commit fc26a64

Browse files
committed
add useragent to http requests
1 parent 8f9e10a commit fc26a64

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/util/http.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@ type HttpClientConfig struct {
1717

1818
type HttpClient struct {
1919
Client *http.Client
20+
UserAgent string
2021
}
2122

2223
func NewHttp(cfg HttpClientConfig) *HttpClient {
2324
return &HttpClient{
2425
Client: &http.Client{
2526
Timeout: time.Duration(cfg.Timeout) * time.Second,
2627
},
28+
UserAgent: "Explo (+https://github.com/LumePart/explo))",
2729
}
2830
}
2931

@@ -34,6 +36,7 @@ func (c *HttpClient) MakeRequest(method, url string, payload io.Reader, headers
3436
}
3537
req.Header.Add("Content-Type", "application/json")
3638
req.Header.Add("Accept", "application/json")
39+
req.Header.Add("User-Agent", c.UserAgent)
3740

3841
for key, value := range headers {
3942
req.Header.Add(key, value)

0 commit comments

Comments
 (0)