Skip to content

Commit

Permalink
Cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
westy92 committed May 8, 2024
1 parent d9e7c55 commit f361f50
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 114 deletions.
22 changes: 9 additions & 13 deletions api_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,19 @@ func (api ApiProvider) baseUrl() string {
}

func (api ApiProvider) extractRateLimitInfo(headers http.Header) RateLimit {
var limit, remaining int
switch api {
case ApiLayer:
limit, _ := strconv.Atoi(headers.Get("x-ratelimit-limit-month"))
remaining, _ := strconv.Atoi(headers.Get("x-ratelimit-remaining-month"))
return RateLimit{
Limit: limit,
Remaining: remaining,
}
limit, _ = strconv.Atoi(headers.Get("x-ratelimit-limit-month"))
remaining, _ = strconv.Atoi(headers.Get("x-ratelimit-remaining-month"))
case RapidApi:
limit, _ := strconv.Atoi(headers.Get("x-ratelimit-requests-limit"))
remaining, _ := strconv.Atoi(headers.Get("x-ratelimit-requests-remaining"))
return RateLimit{
Limit: limit,
Remaining: remaining,
}
limit, _ = strconv.Atoi(headers.Get("x-ratelimit-requests-limit"))
remaining, _ = strconv.Atoi(headers.Get("x-ratelimit-requests-remaining"))
default:
return RateLimit{}
}
return RateLimit{
Limit: limit,
Remaining: remaining,
}
}

Expand Down
Loading

0 comments on commit f361f50

Please sign in to comment.