From 47ea0daaa700bef6ab881f3c2fa4d6605366db26 Mon Sep 17 00:00:00 2001 From: Thomas Schneider <thomas@fsmpi.rwth-aachen.de> Date: Wed, 29 Jun 2022 22:19:20 +0200 Subject: [PATCH] CreateRecord: more debugging log, hopefully --- rwthdns.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/rwthdns.go b/rwthdns.go index 210d5fb..f84b601 100644 --- a/rwthdns.go +++ b/rwthdns.go @@ -3,6 +3,7 @@ package rwthdns import ( "encoding/json" "fmt" + "io" "net/http" "net/url" "strings" @@ -155,9 +156,18 @@ func (c *Client) CreateRecord(content string) (Record, error) { return Record{}, err } - dec := json.NewDecoder(res.Body) + b, err := io.ReadAll(res.Body) + if err != nil { + return Record{}, err + } + bs := string(b) + + dec := json.NewDecoder(strings.NewReader(bs)) var r Record err = dec.Decode(&r) + if err != nil { + err = fmt.Errorf("Decode: %w (%s)", err, bs) + } return r, err } -- GitLab