Подготовить HY2XS к production-сборке

This commit is contained in:
2026-04-25 23:13:12 +05:00
commit 84a4e94567
277 changed files with 26513 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
package middleware
import (
"github.com/didip/tollbooth"
"github.com/didip/tollbooth/limiter"
"github.com/gin-gonic/gin"
"hy2xs-admin/model/vo"
)
var limit *limiter.Limiter
func init() {
limit = tollbooth.NewLimiter(5, nil)
}
func RateLimiterHandler() gin.HandlerFunc {
return func(c *gin.Context) {
httpError := tollbooth.LimitByRequest(limit, c.Writer, c.Request)
if httpError != nil {
vo.Fail("click too fast", c)
c.Abort()
return
}
c.Next()
}
}