Struct: middleware.RequestUserAgent

import "../ibm-cos-sdk-go-v2/aws/middleware"

Overview

RequestUserAgent is a build middleware that set the User-Agent for the request.

Implemented Interfaces

types.AnalyticsFilter, v4.HTTPPresigner, s3.HTTPPresignerV4, types.MetricsFilter, s3.PresignPost, arn.S3ObjectLambdaARN, types.SelectObjectContentEventStream

Constructor Functions collapse

Method Summary collapse

Function Details

func NewRequestUserAgent() *RequestUserAgent

NewRequestUserAgent returns a new requestUserAgent which will set the User-Agent and X-Amz-User-Agent for the request.

User-Agent example:

ibm-cos-sdk-go-v2/1.2.3

X-Amz-User-Agent example:

ibm-cos-sdk-go-v2/1.2.3 md/GOOS/linux md/GOARCH/amd64 lang/go/1.15


178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
// File 'aws/middleware/user_agent.go', line 178

func NewRequestUserAgent() *RequestUserAgent { userAgent, sdkAgent := smithyhttp.NewUserAgentBuilder(), smithyhttp.NewUserAgentBuilder() addProductName(userAgent) addUserAgentMetadata(userAgent) addProductName(sdkAgent) r := &RequestUserAgent{ sdkAgent: sdkAgent, userAgent: userAgent, features: map[UserAgentFeature]struct{}{}, } addSDKMetadata(r) return r }

Method Details

func (u *RequestUserAgent) AddCredentialsSource(source aws.CredentialSource)

AddCredentialsSource adds the credential source as a feature on the User-Agent string



315
316
317
318
319
320
// File 'aws/middleware/user_agent.go', line 315

func (u *RequestUserAgent) AddCredentialsSource(source aws.CredentialSource) { x, ok := credentialSourceToFeature[source] if ok { u.AddUserAgentFeature(x) } }

func (u *RequestUserAgent) AddSDKAgentKey(keyType SDKAgentKeyType, key string)

AddSDKAgentKey adds the component identified by name to the User-Agent string.



303
304
305
306
// File 'aws/middleware/user_agent.go', line 303

func (u *RequestUserAgent) AddSDKAgentKey(keyType SDKAgentKeyType, key string) { // TODO: should target sdkAgent u.userAgent.AddKey(keyType.string() + "/" + strings.Map(rules, key)) }

func (u *RequestUserAgent) AddSDKAgentKeyValue(keyType SDKAgentKeyType, key, value string)

AddSDKAgentKeyValue adds the key identified by the given name and value to the User-Agent string.



309
310
311
312
// File 'aws/middleware/user_agent.go', line 309

func (u *RequestUserAgent) AddSDKAgentKeyValue(keyType SDKAgentKeyType, key, value string) { // TODO: should target sdkAgent u.userAgent.AddKeyValue(keyType.string(), strings.Map(rules, key)+"#"+strings.Map(rules, value)) }

func (u *RequestUserAgent) AddUserAgentFeature(feature UserAgentFeature)

AddUserAgentFeature adds the feature ID to the tracking list to be emitted in the final User-Agent string.



298
299
300
// File 'aws/middleware/user_agent.go', line 298

func (u *RequestUserAgent) AddUserAgentFeature(feature UserAgentFeature) { u.features[feature] = struct{}{} }

func (u *RequestUserAgent) AddUserAgentKey(key string)

AddUserAgentKey adds the component identified by name to the User-Agent string.



287
288
289
// File 'aws/middleware/user_agent.go', line 287

func (u *RequestUserAgent) AddUserAgentKey(key string) { u.userAgent.AddKey(strings.Map(rules, key)) }

func (u *RequestUserAgent) AddUserAgentKeyValue(key, value string)

AddUserAgentKeyValue adds the key identified by the given name and value to the User-Agent string.



292
293
294
// File 'aws/middleware/user_agent.go', line 292

func (u *RequestUserAgent) AddUserAgentKeyValue(key, value string) { u.userAgent.AddKeyValue(strings.Map(rules, key), strings.Map(rules, value)) }

func (u *RequestUserAgent) ID() string

ID the name of the middleware.



323
324
325
// File 'aws/middleware/user_agent.go', line 323

func (u *RequestUserAgent) ID() string { return "UserAgent" }