17
func (c Client) computeHmac256(message string) string {
18
h := hmac.New(sha256.New, c.accountKey)
19
h.Write([]byte(message))
20
return base64.StdEncoding.EncodeToString(h.Sum(nil))
23
func currentTimeRfc1123Formatted() string {
24
return timeRfc1123Formatted(time.Now().UTC())
27
func timeRfc1123Formatted(t time.Time) string {
28
return t.Format(http.TimeFormat)
31
func mergeParams(v1, v2 url.Values) url.Values {
33
for k, v := range v1 {
36
for k, v := range v2 {
39
vals = append(vals, v...)
48
func prepareBlockListRequest(blocks []Block) string {
49
s := `<?xml version="1.0" encoding="utf-8"?><BlockList>`
50
for _, v := range blocks {
51
s += fmt.Sprintf("<%s>%s</%s>", v.Status, v.ID, v.Status)
57
func xmlUnmarshal(body io.Reader, v interface{}) error {
58
data, err := ioutil.ReadAll(body)
62
return xml.Unmarshal(data, v)
65
func xmlMarshal(v interface{}) (io.Reader, int, error) {
66
b, err := xml.Marshal(v)
70
return bytes.NewReader(b), len(b), nil