-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
39 lines (32 loc) · 681 Bytes
/
main.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
package main
import (
"log"
"net/http"
aws4 "github.com/Demoliang/aws4-ec2/v4"
)
const (
REGION = "REGION-1"
SERVICE = "SERVICE-1"
)
func main() {
keys := aws4.Key{
AccessKey: "access_key",
SecretKey: "secret_key",
}
url := "http://127.0.0.1:8080/health"
req, err := http.NewRequest("GET", url, nil)
if err != nil {
panic(err)
}
_, err = aws4.SignRequestWithAwsV4(req, &keys, REGION, SERVICE)
if err != nil {
log.Printf("sign request error:%v", err)
return
}
_, _, err = aws4.CheckRequestWithAwsV4(req, &keys, REGION, SERVICE)
if err != nil {
log.Printf("check request error:%v", err)
return
}
log.Printf("sign success and check success")
}