mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
HETZNER: Don't use string.Title() (#2179)
Co-authored-by: Tom Limoncelli <tlimoncelli@stackoverflow.com>
This commit is contained in:
@@ -33,19 +33,24 @@ func checkIsLockedSystemRecord(record record) error {
|
||||
}
|
||||
|
||||
func getHomogenousDelay(headers http.Header, quotaName string) (time.Duration, error) {
|
||||
quota, err := parseHeaderAsInt(headers, "X-Ratelimit-Limit-"+strings.Title(quotaName))
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
var unit time.Duration
|
||||
var unitHeader string
|
||||
switch quotaName {
|
||||
case "hour":
|
||||
unit = time.Hour
|
||||
unitHeader = "Hour"
|
||||
case "minute":
|
||||
unit = time.Minute
|
||||
unitHeader = "Minute"
|
||||
case "second":
|
||||
unit = time.Second
|
||||
unitHeader = "Second"
|
||||
}
|
||||
|
||||
quota, err := parseHeaderAsInt(headers, "X-Ratelimit-Limit-"+unitHeader)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
delay := time.Duration(int64(unit) / quota)
|
||||
|
Reference in New Issue
Block a user