整理配置文件,jwt过期时间和缓冲时间支持1d2h3m4s事件类型 (#1218)

* feat: human duration

* Update config.yaml

* 调整配置文件结构

Co-authored-by: songzhibin97 <718428482@qq.com>
This commit is contained in:
奇淼(piexlmax
2022-09-13 16:26:02 +08:00
committed by GitHub
co-authored by songzhibin97
parent ee7b9b0cff
commit b5c79be625
10 changed files with 143 additions and 94 deletions
+23
View File
@@ -0,0 +1,23 @@
package utils
import (
"strconv"
"strings"
"time"
)
func ParseDuration(d string) (time.Duration, error) {
dr, err := time.ParseDuration(d)
if err == nil {
return dr, nil
}
if strings.HasSuffix(d, "d") {
h := strings.TrimSuffix(d, "d")
hour, _ := strconv.Atoi(h)
dr = time.Hour * 24 * time.Duration(hour)
return dr, nil
}
dv, err := strconv.ParseInt(d, 10, 64)
return time.Duration(dv), err
}