Skip to content

Commit

Permalink
Merge pull request #66 from atlanhq/FT-773
Browse files Browse the repository at this point in the history
FT-773: Added x-atlan-client-origin header and centralize Version Handling using `go:embed`
  • Loading branch information
0xquark authored Nov 26, 2024
2 parents a64025a + 038ffb9 commit dae9657
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
11 changes: 5 additions & 6 deletions atlan/assets/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"github.com/atlanhq/atlan-go/config"
"io"
"net/http"
"net/url"
Expand Down Expand Up @@ -108,17 +109,15 @@ func configureClient() (*http.Client, *logger.Logger) {

// defaultRequestParams returns default request parameters.
func defaultRequestParams(apiKey string) map[string]interface{} {
VERSION := "0.0"
headers := map[string]string{
"x-atlan-agent": "sdk",
"x-atlan-agent-id": "go",
"User-Agent": fmt.Sprintf("Atlan-GOSDK/%s", VERSION),
"x-atlan-agent": "sdk",
"x-atlan-agent-id": "go",
"x-atlan-client-origin": "product_sdk",
"User-Agent": fmt.Sprintf("Atlan-GOSDK/%s", config.Version()),
}

headers["Authorization"] = "Bearer " + apiKey
headers["Accept"] = "application/json"
headers["Content-type"] = "application/json"

return map[string]interface{}{
"headers": headers,
}
Expand Down
File renamed without changes.
14 changes: 14 additions & 0 deletions config/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package config

import (
_ "embed"
"strings"
)

//go:embed VERSION
var versionFile string

// Version returns the SDK version.
func Version() string {
return strings.TrimSpace(versionFile)
}

0 comments on commit dae9657

Please sign in to comment.