Skip to content

Commit

Permalink
Set a user agent for each request
Browse files Browse the repository at this point in the history
  • Loading branch information
ldmberman committed Nov 5, 2015
1 parent 0a8a12d commit fd84645
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions base/constants.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package base

const (
VERSION = "built-from-source"
)

var (
URL = "https://api.ctl.io"
TIME_FORMAT = "2006-01-02 15:04:05"
Expand Down
2 changes: 2 additions & 0 deletions connection/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"net/http/httputil"
"net/url"
"reflect"
"runtime"
"strings"

"github.com/centurylinkcloud/clc-go-cli/base"
Expand Down Expand Up @@ -149,6 +150,7 @@ func (cn *connection) prepareRequest(verb string, url string, reqModel interface
url = FilterQuery(url)
req, err = http.NewRequest(verb, url, inputData)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("User-Agent", fmt.Sprintf("clc-go-cli-%s-%s", base.VERSION, runtime.GOOS))
if err != nil {
return nil, err
}
Expand Down

0 comments on commit fd84645

Please sign in to comment.