aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/aws/aws-sdk-go/private/protocol/host_prefix.go
diff options
context:
space:
mode:
authorNathan Dench <ndenc2@gmail.com>2019-05-24 15:16:44 +1000
committerNathan Dench <ndenc2@gmail.com>2019-05-24 15:16:44 +1000
commit107c1cdb09c575aa2f61d97f48d8587eb6bada4c (patch)
treeca7d008643efc555c388baeaf1d986e0b6b3e28c /vendor/github.com/aws/aws-sdk-go/private/protocol/host_prefix.go
parent844b5a68d8af4791755b8f0ad293cc99f5959183 (diff)
downloadterraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.tar.gz
terraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.tar.zst
terraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.zip
Upgrade to 0.12
Diffstat (limited to 'vendor/github.com/aws/aws-sdk-go/private/protocol/host_prefix.go')
-rw-r--r--vendor/github.com/aws/aws-sdk-go/private/protocol/host_prefix.go54
1 files changed, 54 insertions, 0 deletions
diff --git a/vendor/github.com/aws/aws-sdk-go/private/protocol/host_prefix.go b/vendor/github.com/aws/aws-sdk-go/private/protocol/host_prefix.go
new file mode 100644
index 0000000..915b0fc
--- /dev/null
+++ b/vendor/github.com/aws/aws-sdk-go/private/protocol/host_prefix.go
@@ -0,0 +1,54 @@
1package protocol
2
3import (
4 "strings"
5
6 "github.com/aws/aws-sdk-go/aws"
7 "github.com/aws/aws-sdk-go/aws/request"
8)
9
10// HostPrefixHandlerName is the handler name for the host prefix request
11// handler.
12const HostPrefixHandlerName = "awssdk.endpoint.HostPrefixHandler"
13
14// NewHostPrefixHandler constructs a build handler
15func NewHostPrefixHandler(prefix string, labelsFn func() map[string]string) request.NamedHandler {
16 builder := HostPrefixBuilder{
17 Prefix: prefix,
18 LabelsFn: labelsFn,
19 }
20
21 return request.NamedHandler{
22 Name: HostPrefixHandlerName,
23 Fn: builder.Build,
24 }
25}
26
27// HostPrefixBuilder provides the request handler to expand and prepend
28// the host prefix into the operation's request endpoint host.
29type HostPrefixBuilder struct {
30 Prefix string
31 LabelsFn func() map[string]string
32}
33
34// Build updates the passed in Request with the HostPrefix template expanded.
35func (h HostPrefixBuilder) Build(r *request.Request) {
36 if aws.BoolValue(r.Config.DisableEndpointHostPrefix) {
37 return
38 }
39
40 var labels map[string]string
41 if h.LabelsFn != nil {
42 labels = h.LabelsFn()
43 }
44
45 prefix := h.Prefix
46 for name, value := range labels {
47 prefix = strings.Replace(prefix, "{"+name+"}", value, -1)
48 }
49
50 r.HTTPRequest.URL.Host = prefix + r.HTTPRequest.URL.Host
51 if len(r.HTTPRequest.Host) > 0 {
52 r.HTTPRequest.Host = prefix + r.HTTPRequest.Host
53 }
54}