blob: ae8ba19943444c73e03bfb6da779f7ce70d4e408 [file] [log] [blame]
Jon Perritt816d2a02014-03-11 20:49:46 -05001package accounts
2
3import (
4 "strings"
5)
6
7type UpdateOpts struct {
8 Metadata map[string]string
9 Headers map[string]string
10}
11
12type GetOpts struct {
13 Headers map[string]string
14}
15
Jon Perritteb575642014-04-24 15:16:31 -050016// ExtractMetadata is a function that takes a GetResult (of type *http.Response)
Jon Perritt816d2a02014-03-11 20:49:46 -050017// and returns the custom metatdata associated with the account.
Jon Perritteb575642014-04-24 15:16:31 -050018func ExtractMetadata(gr GetResult) map[string]string {
Jon Perritt816d2a02014-03-11 20:49:46 -050019 metadata := make(map[string]string)
Jon Perritteb575642014-04-24 15:16:31 -050020 for k, v := range gr.Header {
Jon Perritt816d2a02014-03-11 20:49:46 -050021 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}