Sha256: 47d6511e58160149cbabd5485f3c59b1408b024f0970388a199985471adb649a

Contents?: true

Size: 885 Bytes

Versions: 16

Compression:

Stored size: 885 Bytes

Contents

package http

import (
	"strings"
)

// UserAgentBuilder is a builder for a HTTP User-Agent string.
type UserAgentBuilder struct {
	sb strings.Builder
}

// NewUserAgentBuilder returns a new UserAgentBuilder.
func NewUserAgentBuilder() *UserAgentBuilder {
	return &UserAgentBuilder{sb: strings.Builder{}}
}

// AddKey adds the named component/product to the agent string
func (u *UserAgentBuilder) AddKey(key string) {
	u.appendTo(key)
}

// AddKeyValue adds the named key to the agent string with the given value.
func (u *UserAgentBuilder) AddKeyValue(key, value string) {
	u.appendTo(key + "/" + value)
}

// Build returns the constructed User-Agent string. May be called multiple times.
func (u *UserAgentBuilder) Build() string {
	return u.sb.String()
}

func (u *UserAgentBuilder) appendTo(value string) {
	if u.sb.Len() > 0 {
		u.sb.WriteRune(' ')
	}
	u.sb.WriteString(value)
}

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
ruby_snowflake_client-1.3.7 ext/vendor/github.com/aws/smithy-go/transport/http/user_agent.go
ruby_snowflake_client-1.3.6 ext/vendor/github.com/aws/smithy-go/transport/http/user_agent.go
ruby_snowflake_client-1.3.5 ext/vendor/github.com/aws/smithy-go/transport/http/user_agent.go
ruby_snowflake_client-1.3.4 ext/vendor/github.com/aws/smithy-go/transport/http/user_agent.go
ruby_snowflake_client-1.3.4.pre.debug ext/vendor/github.com/aws/smithy-go/transport/http/user_agent.go
ruby_snowflake_client-1.3.3.pre.debug ext/vendor/github.com/aws/smithy-go/transport/http/user_agent.go
ruby_snowflake_client-1.3.2 ext/vendor/github.com/aws/smithy-go/transport/http/user_agent.go
ruby_snowflake_client-1.3.1 ext/vendor/github.com/aws/smithy-go/transport/http/user_agent.go
ruby_snowflake_client-1.3.0 ext/vendor/github.com/aws/smithy-go/transport/http/user_agent.go
ruby_snowflake_client-1.2.1 ext/vendor/github.com/aws/smithy-go/transport/http/user_agent.go
ruby_snowflake_client-1.2.0 ext/vendor/github.com/aws/smithy-go/transport/http/user_agent.go
ruby_snowflake_client-1.1.1 ext/vendor/github.com/aws/smithy-go/transport/http/user_agent.go
ruby_snowflake_client-1.1.0 ext/vendor/github.com/aws/smithy-go/transport/http/user_agent.go
ruby_snowflake_client-1.0.2 ext/vendor/github.com/aws/smithy-go/transport/http/user_agent.go
ruby_snowflake_client-1.0.1 ext/vendor/github.com/aws/smithy-go/transport/http/user_agent.go
ruby_snowflake_client-1.0.0 ext/vendor/github.com/aws/smithy-go/transport/http/user_agent.go