Add version to user agent
This commit is contained in:
parent
f86c28b0a5
commit
36df906bbb
16
client.go
16
client.go
@ -10,6 +10,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -71,6 +72,12 @@ var errorMap = map[int]error{
|
|||||||
523: errors.New("Something went wrong on LIFX's end"),
|
523: errors.New("Something went wrong on LIFX's end"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var userAgent string
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
userAgent = initUserAgent()
|
||||||
|
}
|
||||||
|
|
||||||
func NewClient(accessToken string, options ...func(*Client)) *Client {
|
func NewClient(accessToken string, options ...func(*Client)) *Client {
|
||||||
var c *Client
|
var c *Client
|
||||||
tr := &http.Transport{
|
tr := &http.Transport{
|
||||||
@ -333,3 +340,12 @@ func (c *Client) stateDelta(selector string, delta StateDelta) (*Response, error
|
|||||||
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func initUserAgent() string {
|
||||||
|
var b strings.Builder
|
||||||
|
|
||||||
|
b.WriteString("lifx-go")
|
||||||
|
b.WriteRune('/')
|
||||||
|
b.WriteString(Version)
|
||||||
|
return b.String()
|
||||||
|
}
|
||||||
|
3
version.go
Normal file
3
version.go
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
package lifx
|
||||||
|
|
||||||
|
const Version = "0.1.0-pre"
|
Loading…
Reference in New Issue
Block a user