Browse Source

Fall back to default User-Agent when making request

Matt Baer 1 year ago
parent
commit
2bd4aedf4c
1 changed files with 5 additions and 1 deletions
  1. 5
    1
      api.go

+ 5
- 1
api.go View File

@@ -107,7 +107,11 @@ func (c *Client) doRequest(r *http.Request, result interface{}) (*impart.Envelop
107 107
 }
108 108
 
109 109
 func (c *Client) prepareRequest(r *http.Request) {
110
-	r.Header.Add("User-Agent", c.Config.UserAgent)
110
+	ua := c.Config.UserAgent
111
+	if ua == "" {
112
+		ua = "go-as-api v1"
113
+	}
114
+	r.Header.Add("User-Agent", ua)
111 115
 	r.Header.Add("Content-Type", "application/json")
112 116
 	if c.Token != "" {
113 117
 		r.Header.Add("Authorization", "Token "+c.Token)