Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var IPMiddleware = zutil.Once(func() func(c *znet.Context) error { limit := limiter.NewRule() if MaxIPRequestPerSecond == 0 { MaxIPRequestPerSecond = 10 } limit.AddRule(time.Second, MaxIPRequestPerSecond) tooManyRequestsTag := zerror.WrapTag(zerror.TagKind(ztype.ToString(http.StatusTooManyRequests)))(errors.New("Too many requests")) return func(c *znet.Context) error { if !limit.AllowVisitByIP(c.GetClientIP()) { return tooManyRequestsTag } c.Next() return nil } })
View Source
var MaxIPRequestPerSecond = 10
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.