-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
48 lines (40 loc) · 815 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
40
41
42
43
44
45
46
47
48
package main
import (
"bytes"
"crypto/tls"
"encoding/json"
"fmt"
"log"
"net/http"
)
func main() {
endpoint := "insert_your_endpoint"
token := "insert_your_token"
isHTTPS := false
message := map[string]interface{}{
"jsonrpc": "2.0",
"id": 1,
"method": "backup",
"params": map[string]string{
"authToken": token,
},
}
bytesRepresentation, err := json.Marshal(message)
var tr *http.Transport
if isHTTPS {
tr = &http.Transport{}
} else {
tr = &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
}
client := &http.Client{Transport: tr}
req, err := http.NewRequest("POST", fmt.Sprintf("%s", endpoint), bytes.NewBuffer(bytesRepresentation))
if err != nil {
log.Println(err)
}
_, err = client.Do(req)
if err != nil {
log.Println(err)
}
}