diff options
author | Nathan Dench <ndenc2@gmail.com> | 2019-05-24 15:16:44 +1000 |
---|---|---|
committer | Nathan Dench <ndenc2@gmail.com> | 2019-05-24 15:16:44 +1000 |
commit | 107c1cdb09c575aa2f61d97f48d8587eb6bada4c (patch) | |
tree | ca7d008643efc555c388baeaf1d986e0b6b3e28c /vendor/github.com/aws/aws-sdk-go/private/protocol/host_prefix.go | |
parent | 844b5a68d8af4791755b8f0ad293cc99f5959183 (diff) | |
download | terraform-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.go | 54 |
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 @@ | |||
1 | package protocol | ||
2 | |||
3 | import ( | ||
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. | ||
12 | const HostPrefixHandlerName = "awssdk.endpoint.HostPrefixHandler" | ||
13 | |||
14 | // NewHostPrefixHandler constructs a build handler | ||
15 | func 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. | ||
29 | type 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. | ||
35 | func (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 | } | ||