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/google.golang.org/api/googleapi/transport | |
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/google.golang.org/api/googleapi/transport')
-rw-r--r-- | vendor/google.golang.org/api/googleapi/transport/apikey.go | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/vendor/google.golang.org/api/googleapi/transport/apikey.go b/vendor/google.golang.org/api/googleapi/transport/apikey.go new file mode 100644 index 0000000..eca1ea2 --- /dev/null +++ b/vendor/google.golang.org/api/googleapi/transport/apikey.go | |||
@@ -0,0 +1,38 @@ | |||
1 | // Copyright 2012 Google Inc. All rights reserved. | ||
2 | // Use of this source code is governed by a BSD-style | ||
3 | // license that can be found in the LICENSE file. | ||
4 | |||
5 | // Package transport contains HTTP transports used to make | ||
6 | // authenticated API requests. | ||
7 | package transport | ||
8 | |||
9 | import ( | ||
10 | "errors" | ||
11 | "net/http" | ||
12 | ) | ||
13 | |||
14 | // APIKey is an HTTP Transport which wraps an underlying transport and | ||
15 | // appends an API Key "key" parameter to the URL of outgoing requests. | ||
16 | type APIKey struct { | ||
17 | // Key is the API Key to set on requests. | ||
18 | Key string | ||
19 | |||
20 | // Transport is the underlying HTTP transport. | ||
21 | // If nil, http.DefaultTransport is used. | ||
22 | Transport http.RoundTripper | ||
23 | } | ||
24 | |||
25 | func (t *APIKey) RoundTrip(req *http.Request) (*http.Response, error) { | ||
26 | rt := t.Transport | ||
27 | if rt == nil { | ||
28 | rt = http.DefaultTransport | ||
29 | if rt == nil { | ||
30 | return nil, errors.New("googleapi/transport: no Transport specified or available") | ||
31 | } | ||
32 | } | ||
33 | newReq := *req | ||
34 | args := newReq.URL.Query() | ||
35 | args.Set("key", t.Key) | ||
36 | newReq.URL.RawQuery = args.Encode() | ||
37 | return rt.RoundTrip(&newReq) | ||
38 | } | ||