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 | |
| 16 | // GetMetadata is a function that takes a GetResult (of type *perigee.Response) |
| 17 | // and returns the custom metatdata associated with the account. |
| 18 | func GetMetadata(gr GetResult) map[string]string { |
| 19 | metadata := make(map[string]string) |
| 20 | for k, v := range gr.HttpResponse.Header { |
| 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 | } |