aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/host_id.go
blob: 85b60d2a1b92c009c0e76d6ee919c78a603e9f8f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package s3shared

import (
	"github.com/aws/smithy-go/middleware"
)

// hostID is used to retrieve host id from response metadata
type hostID struct {
}

// SetHostIDMetadata sets the provided host id over middleware metadata
func SetHostIDMetadata(metadata *middleware.Metadata, id string) {
	metadata.Set(hostID{}, id)
}

// GetHostIDMetadata retrieves the host id from middleware metadata
// returns host id as string along with a boolean indicating presence of
// hostId on middleware metadata.
func GetHostIDMetadata(metadata middleware.Metadata) (string, bool) {
	if !metadata.Has(hostID{}) {
		return "", false
	}

	v, ok := metadata.Get(hostID{}).(string)
	if !ok {
		return "", true
	}
	return v, true
}