-
Notifications
You must be signed in to change notification settings - Fork 22
/
example_test.go
54 lines (44 loc) · 1.05 KB
/
example_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package aws4_test
import (
"fmt"
"github.com/bmizerany/aws4"
"log"
"net/http"
"net/url"
"strings"
)
func Example_jSONBody() {
data := strings.NewReader("{}")
r, _ := http.NewRequest("POST", "https://dynamodb.us-east-1.amazonaws.com/", data)
r.Header.Set("Content-Type", "application/x-amz-json-1.0")
r.Header.Set("X-Amz-Target", "DynamoDB_20111205.ListTables")
resp, err := aws4.DefaultClient.Do(r)
if err != nil {
log.Fatal(err)
}
fmt.Println(resp.StatusCode)
// Output:
// 200
}
func Example_formEncodedBody() {
v := make(url.Values)
v.Set("Action", "DescribeAutoScalingGroups")
resp, err := aws4.PostForm("https://autoscaling.us-east-1.amazonaws.com/", v)
if err != nil {
log.Fatal(err)
}
fmt.Println(resp.StatusCode)
// Output:
// 200
}
func ExampleSignGlacier() {
r, _ := http.NewRequest("GET", "https://glacier.us-east-1.amazonaws.com/-/vaults", nil)
r.Header.Set("X-Amz-Glacier-Version", "2012-06-01")
resp, err := aws4.DefaultClient.Do(r)
if err != nil {
log.Fatal(err)
}
fmt.Println(resp.StatusCode)
// Output:
// 200
}