CLI User Agent Header (#2591)
diff --git a/whisk/api.go b/whisk/api.go
index 0d318d2..4a30118 100644
--- a/whisk/api.go
+++ b/whisk/api.go
@@ -45,7 +45,6 @@
Skip int `url:"skip"`
Docs bool `url:"docs,omitempty"`
}
-//type ApiListResponse RetApiArray
type ApiListResponse RetApiArray
// wsk api get : Request, Response
@@ -105,7 +104,7 @@
type ApiItem struct {
ApiId string `json:"id,omitempty"`
QueryKey string `json:"key,omitempty"`
- ApiValue *RetApi `json:"value,omitempty"`
+ ApiValue *RetApi `json:"value,omitempty"`
}
type RetApi struct {
diff --git a/whisk/client.go b/whisk/client.go
index c8cb311..5fe0b14 100644
--- a/whisk/client.go
+++ b/whisk/client.go
@@ -77,6 +77,7 @@
Verbose bool
Debug bool // For detailed tracing
Insecure bool
+ UserAgent string
}
func NewClient(httpClient *http.Client, config_input *Config) (*Client, error) {
@@ -147,6 +148,10 @@
config.Version = "v1"
}
+ if len(config.UserAgent) == 0 {
+ config.UserAgent = "OpenWhisk-Go-Client"
+ }
+
c := &Client{
client: httpClient,
Config: config,
@@ -225,6 +230,8 @@
return nil, werr
}
+ req.Header.Add("User-Agent", c.Config.UserAgent)
+
return req, nil
}
@@ -673,5 +680,7 @@
Debug(DbgInfo, "No auth header required\n")
}
+ req.Header.Add("User-Agent", c.Config.UserAgent)
+
return req, nil
}