Jamie Hannaford | 93209fe | 2014-10-10 11:54:19 +0200 | [diff] [blame^] | 1 | package accounts |
| 2 | |
| 3 | import ( |
| 4 | "net/http" |
| 5 | "strings" |
| 6 | ) |
| 7 | |
| 8 | // GetResult is a *http.Response that is returned from a call to the Get function. |
| 9 | type GetResult *http.Response |
| 10 | |
| 11 | // ExtractMetadata is a function that takes a GetResult (of type *http.Response) |
| 12 | // and returns the custom metatdata associated with the account. |
| 13 | func ExtractMetadata(gr GetResult) map[string]string { |
| 14 | metadata := make(map[string]string) |
| 15 | for k, v := range gr.Header { |
| 16 | if strings.HasPrefix(k, "X-Account-Meta-") { |
| 17 | key := strings.TrimPrefix(k, "X-Account-Meta-") |
| 18 | metadata[key] = v[0] |
| 19 | } |
| 20 | } |
| 21 | return metadata |
| 22 | } |