projects
/
kraftakt.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Check status code when calling the subscription API.
[kraftakt.git]
/
gfitsync.go
diff --git
a/gfitsync.go
b/gfitsync.go
index
21f764b
..
614d513
100644
(file)
--- a/
gfitsync.go
+++ b/
gfitsync.go
@@
-152,8
+152,16
@@
func fitbitGrantHandler(ctx context.Context, w http.ResponseWriter, r *http.Requ
}
defer res.Body.Close()
}
defer res.Body.Close()
+ if res.StatusCode >= 400 {
+ data, _ := ioutil.ReadAll(r.Body)
+ log.Errorf(ctx, "creating subscription failed: status %d %q", res.StatusCode, data)
+ return fmt.Errorf("creating subscription failed")
+ }
+
redirectURL := r.URL
redirectURL.Path = "/"
redirectURL := r.URL
redirectURL.Path = "/"
+ redirectURL.RawQuery = ""
+ redirectURL.Fragment = ""
http.Redirect(w, r, redirectURL.String(), http.StatusTemporaryRedirect)
return nil
}
http.Redirect(w, r, redirectURL.String(), http.StatusTemporaryRedirect)
return nil
}