From 6c820412cf4e69ce85ec4bb93eb71fad19d8e3ad Mon Sep 17 00:00:00 2001 From: noisypixy Date: Wed, 2 Mar 2016 19:22:57 -0430 Subject: [PATCH 1/2] Replace HTTP status codes for net/http constants. --- restapi.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/restapi.go b/restapi.go index daa5b50..dc26baf 100644 --- a/restapi.go +++ b/restapi.go @@ -104,15 +104,14 @@ func (s *Session) request(method, urlStr, contentType string, b []byte) (respons fmt.Printf("API RESPONSE BODY :: [%s]\n", response) } - // See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html switch resp.StatusCode { - case 200: // OK - case 204: // No Content + case http.StatusOK: + case http.StatusNoContent: // TODO check for 401 response, invalidate token if we get one. - case 429: // TOO MANY REQUESTS - Rate limiting + case http.StatusTooManyRequests: // Rate limiting rl := RateLimit{} err = json.Unmarshal(response, &rl) if err != nil { From ce9840f8c43c6d2421c6995b3fbdd3d8839291a9 Mon Sep 17 00:00:00 2001 From: noisypixy Date: Wed, 2 Mar 2016 21:13:53 -0430 Subject: [PATCH 2/2] Constant missing in Go < 1.6 --- restapi.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/restapi.go b/restapi.go index dc26baf..93b71ea 100644 --- a/restapi.go +++ b/restapi.go @@ -111,7 +111,7 @@ func (s *Session) request(method, urlStr, contentType string, b []byte) (respons // TODO check for 401 response, invalidate token if we get one. - case http.StatusTooManyRequests: // Rate limiting + case 429: // TOO MANY REQUESTS - Rate limiting rl := RateLimit{} err = json.Unmarshal(response, &rl) if err != nil {