blob: 13a894b09e128c3e1d2f6c3ceca29432d0b1bc50 [file] [log] [blame]
Jamie Hannaford93209fe2014-10-10 11:54:19 +02001package accounts
2
3import (
4 "net/http"
5 "strings"
6)
7
8// GetResult is a *http.Response that is returned from a call to the Get function.
9type 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.
13func 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}