Skip to content

Commit

Permalink
Updated user agent string
Browse files Browse the repository at this point in the history
  • Loading branch information
SP Singh committed Oct 18, 2021
1 parent f337c24 commit b9bed7e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 5 additions & 1 deletion internal/pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
"net/http"
"net/url"
p "path"
"runtime"
"strings"
"time"

"github.com/smsglobal/smsglobal-go/internal/interface/apiclient"
Expand Down Expand Up @@ -94,9 +96,11 @@ func (c *Client) NewRequest(method, path string, body interface{}) (*http.Reques
req.Header.Add("Accept", constants.ContentType)
req.Header.Add("Accept-Charset", "utf-8")
req.Header.Add("Authorization", c.generateAuthToken())
req.Header.Add("User-Agent", constants.UserAgent)

req.Header.Add("User-Agent", fmt.Sprintf( "SMSGlobal-GO-SDK/v2 Version/%s Go/%s (%s %s)", constants.Version, strings.Replace(runtime.Version(), "go", "",1) , runtime.GOOS, runtime.GOARCH))

// TODO clean up before MR
log.Debug().Msgf("User-Agent: %v", req.Header.Get("User-Agent"))
log.Debug().Msgf("Authorization header: %v", req.Header.Get("Authorization"))

return req, nil
Expand Down
1 change: 0 additions & 1 deletion internal/types/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const (
Host = "https://api.smsglobal.com/v2"
ContentType = "application/json"
Version = "1.0.0"
UserAgent = "SMSGlobal-GO-SDK/" + Version
DefaultCode = -1 //defaultCode is the default error code for non-api related failures. e.g. Missing credentials
DebugLevel = "debug"
Timeout = 30 //request timeout duration in seconds
Expand Down

0 comments on commit b9bed7e

Please sign in to comment.