1 // Copyright 2015 The Go Authors. 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.
10 "google.golang.org/api/googleapi"
13 // URLParams is a simplified replacement for url.Values
14 // that safely builds up URL parameters for encoding.
15 type URLParams map[string][]string
17 // Get returns the first value for the given key, or "".
18 func (u URLParams) Get(key string) string {
26 // Set sets the key to value.
27 // It replaces any existing values.
28 func (u URLParams) Set(key, value string) {
29 u[key] = []string{value}
32 // SetMulti sets the key to an array of values.
33 // It replaces any existing values.
34 // Note that values must not be modified after calling SetMulti
35 // so the caller is responsible for making a copy if necessary.
36 func (u URLParams) SetMulti(key string, values []string) {
40 // Encode encodes the values into ``URL encoded'' form
41 // ("bar=baz&foo=quux") sorted by key.
42 func (u URLParams) Encode() string {
43 return url.Values(u).Encode()
46 // SetOptions sets the URL params and any additional call options.
47 func SetOptions(u URLParams, opts ...googleapi.CallOption) {
48 for _, o := range opts {