Skip to content

Commit

Permalink
Adding more info to user-agent
Browse files Browse the repository at this point in the history
  • Loading branch information
soareswallace committed Jan 23, 2025
1 parent aef00a6 commit f0cb4a8
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions incognia.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"fmt"
"io/ioutil"
"net/http"
"runtime"
"runtime/debug"
"time"
)

Expand Down Expand Up @@ -384,7 +386,27 @@ func (c *Client) registerLogin(login *Login) (*TransactionAssessment, error) {
}

func (c *Client) doRequest(request *http.Request, response interface{}) error {
buildInfo, ok := debug.ReadBuildInfo()
goVersion := "unknown"
libVersion := "unknown"
if ok {
if buildInfo.Main.Version != "(devel)" {
libVersion = buildInfo.Main.Version
}

goVersion = buildInfo.GoVersion
}

userAgent := fmt.Sprintf(
"incognia-api-go/%s (%s %s) Go/%s",
libVersion,
runtime.GOOS,
runtime.GOARCH,
goVersion,
)

request.Header.Add("Content-Type", "application/json")
request.Header.Add("user-agent", userAgent)

err := c.authorizeRequest(request)
if err != nil {
Expand Down

0 comments on commit f0cb4a8

Please sign in to comment.