获取配置文件代码优化
This commit is contained in:
@@ -23,9 +23,9 @@ func Logger(r *ghttp.Request) {
|
||||
)
|
||||
}
|
||||
|
||||
var rateLimit, _ = g.Cfg().Get(context.TODO(), "rate.limit")
|
||||
var rateBurst, _ = g.Cfg().Get(context.TODO(), "rate.burst")
|
||||
var limiter = rate.NewLimiter(rate.Limit(rateLimit.Int()), rateBurst.Int())
|
||||
var rateLimit = g.Cfg().MustGet(context.TODO(), "rate.limit").Int()
|
||||
var rateBurst = g.Cfg().MustGet(context.TODO(), "rate.burst").Int()
|
||||
var limiter = rate.NewLimiter(rate.Limit(rateLimit), rateBurst)
|
||||
|
||||
func Limiter(r *ghttp.Request) {
|
||||
if !limiter.Allow() {
|
||||
|
||||
Reference in New Issue
Block a user