Skip to content

Commit

Permalink
fix error (#40)
Browse files Browse the repository at this point in the history
* add rate limits to error wrapper

* Update rate_limit.go

* Replace Refresh <--->Remaining

Replace Refresh <--->Remaining

* Update rate_limit.go

* fix model/rate_linit.go
  • Loading branch information
alexwestside authored and BrandonRomano committed May 16, 2018
1 parent 0d71f29 commit dac5e66
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions models/rate_limit.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type TypeRatelimit struct {
func GetLimit(httpResp *http.Response, key string) int {
if val, ok := httpResp.Header[key]; ok {
rateLimit, err := strconv.Atoi(val[0])
if err == nil {
if err != nil {
fmt.Println(err)
return 0
}
Expand All @@ -26,8 +26,9 @@ func GetLimit(httpResp *http.Response, key string) int {

func GetRatelimit(httpResp *http.Response) TypeRatelimit {
return TypeRatelimit {
Remaining: GetLimit(httpResp, "X-Ratelimit-Refresh"),
Remaining: GetLimit(httpResp, "X-Ratelimit-Remaining"),
Limit: GetLimit(httpResp, "X-Ratelimit-Limit"),
Refresh: GetLimit(httpResp, "X-Ratelimit-Remaining"),
Refresh: GetLimit(httpResp, "X-Ratelimit-Refresh"),
}
}
}

0 comments on commit dac5e66

Please sign in to comment.