Browse Source

Fall back to default User-Agent when making request

master
Matt Baer 5 years 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
}

func (c *Client) prepareRequest(r *http.Request) {
r.Header.Add("User-Agent", c.Config.UserAgent)
ua := c.Config.UserAgent
if ua == "" {
ua = "go-as-api v1"
}
r.Header.Add("User-Agent", ua)
r.Header.Add("Content-Type", "application/json")
if c.Token != "" {
r.Header.Add("Authorization", "Token "+c.Token)


Loading…
Cancel
Save