Skip to content

Commit

Permalink
feat: support customized user agent (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhiHanZ committed May 15, 2024
1 parent e34f7ba commit 65b901d
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions restful.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ const (
)

const (
ContextKeyQueryID ContextKey = "X-DATABEND-QUERY-ID"
EMPTY_FIELD_AS string = "empty_field_as"
PURGE string = "purge"
ContextKeyQueryID ContextKey = "X-DATABEND-QUERY-ID"
ContextUserAgentID ContextKey = "USER-AGENT"
EMPTY_FIELD_AS string = "empty_field_as"
PURGE string = "purge"
)

type PresignedResponse struct {
Expand Down Expand Up @@ -293,6 +294,12 @@ func (c *APIClient) authMethod() AuthMethod {
func (c *APIClient) makeHeaders(ctx context.Context) (http.Header, error) {
headers := http.Header{}
headers.Set(WarehouseRoute, "warehouse")
if userAgent, ok := ctx.Value(ContextUserAgentID).(string); ok {
headers.Set(UserAgent, fmt.Sprintf("%s/databend-go/%s", version, userAgent))
} else {
headers.Set(UserAgent, fmt.Sprintf("databend-go/%s", version))

}
headers.Set(UserAgent, fmt.Sprintf("databend-go/%s", version))
if c.tenant != "" {
headers.Set(DatabendTenantHeader, c.tenant)
Expand Down

0 comments on commit 65b901d

Please sign in to comment.