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.
5 // Package transport contains HTTP transports used to make
6 // authenticated API requests.
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.
17 // Key is the API Key to set on requests.
20 // Transport is the underlying HTTP transport.
21 // If nil, http.DefaultTransport is used.
22 Transport http.RoundTripper
25 func (t *APIKey) RoundTrip(req *http.Request) (*http.Response, error) {
28 rt = http.DefaultTransport
30 return nil, errors.New("googleapi/transport: no Transport specified or available")
34 args := newReq.URL.Query()
35 args.Set("key", t.Key)
36 newReq.URL.RawQuery = args.Encode()
37 return rt.RoundTrip(&newReq)