Updated for troubleshooting
This commit is contained in:
parent
fdda8b8a6d
commit
0a0ebd912f
1 changed files with 25 additions and 1 deletions
26
ddns.go
26
ddns.go
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/http/httputil"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
@ -44,8 +45,31 @@ func main() {
|
||||||
|
|
||||||
func getRecord() Record {
|
func getRecord() Record {
|
||||||
body := strings.NewReader(fmt.Sprintf("{\"secretapikey\": \"%s\", \"apikey\": \"%s\"}", os.Getenv(secretKey), os.Getenv(apiKey)))
|
body := strings.NewReader(fmt.Sprintf("{\"secretapikey\": \"%s\", \"apikey\": \"%s\"}", os.Getenv(secretKey), os.Getenv(apiKey)))
|
||||||
|
req, err := http.NewRequest(http.MethodPost, getUrl, body)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
req.Header.Add("Content-type", "application/json")
|
||||||
|
|
||||||
|
reqDump, err := httputil.DumpRequestOut(req, true)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf("REQUEST:\n%s", string(reqDump))
|
||||||
|
|
||||||
|
resp, err := http.DefaultClient.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
respDump, err := httputil.DumpResponse(resp, true)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf("RESPONSE:\n%s", string(respDump))
|
||||||
|
|
||||||
resp, err := http.Post(getUrl, "application/json", body)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue