From bd2d890a9ad1128bf25b560fc4d796249c4ed495 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 3 Jun 2017 14:34:13 +0200 Subject: main.go: Print HTTP response bodies for debugging Previously we were just printing the headers. Now print the bodies to allow us to inspect the result. Will probably want to add some handling that messages the user about authentication problems. --- main.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'main.go') diff --git a/main.go b/main.go index 1cc56c7..2f82643 100644 --- a/main.go +++ b/main.go @@ -2,7 +2,7 @@ package main import ( // "fmt" - // "io/ioutil" + "io/ioutil" "log" // "os" "time" @@ -35,6 +35,10 @@ func main() { } log.Printf("%+v\n", resp) + defer resp.Body.Close() + body, err := ioutil.ReadAll(resp.Body) + log.Println(string(body)) + time_entry := timetask.NewTimeEntry( config.Profile, config.Projects["example"], @@ -48,6 +52,10 @@ func main() { } log.Printf("%+v\n", resp) + defer resp.Body.Close() + body, err = ioutil.ReadAll(resp.Body) + log.Println(string(body)) + // if len(os.Args) == 1 { // fmt.Println("Not enough arguments") // os.Exit(1) -- cgit v1.2.3