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 e875012
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 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,24 @@ func (c *Client) registerLogin(login *Login) (*TransactionAssessment, error) {
}

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

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

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 e875012

Please sign in to comment.