Jon Perritt | 816d2a0 | 2014-03-11 20:49:46 -0500 | [diff] [blame] | 1 | package accounts |
| 2 | |
| 3 | import ( |
| 4 | "strings" |
| 5 | ) |
| 6 | |
| 7 | type UpdateOpts struct { |
| 8 | Metadata map[string]string |
| 9 | Headers map[string]string |
| 10 | } |
| 11 | |
| 12 | type GetOpts struct { |
| 13 | Headers map[string]string |
| 14 | } |
| 15 | |
Jon Perritt | eb57564 | 2014-04-24 15:16:31 -0500 | [diff] [blame^] | 16 | // ExtractMetadata is a function that takes a GetResult (of type *http.Response) |
Jon Perritt | 816d2a0 | 2014-03-11 20:49:46 -0500 | [diff] [blame] | 17 | // and returns the custom metatdata associated with the account. |
Jon Perritt | eb57564 | 2014-04-24 15:16:31 -0500 | [diff] [blame^] | 18 | func ExtractMetadata(gr GetResult) map[string]string { |
Jon Perritt | 816d2a0 | 2014-03-11 20:49:46 -0500 | [diff] [blame] | 19 | metadata := make(map[string]string) |
Jon Perritt | eb57564 | 2014-04-24 15:16:31 -0500 | [diff] [blame^] | 20 | for k, v := range gr.Header { |
Jon Perritt | 816d2a0 | 2014-03-11 20:49:46 -0500 | [diff] [blame] | 21 | if strings.HasPrefix(k, "X-Account-Meta-") { |
| 22 | key := strings.TrimPrefix(k, "X-Account-Meta-") |
| 23 | metadata[key] = v[0] |
| 24 | } |
| 25 | } |
| 26 | return metadata |
| 27 | } |