fix11: runtime contracts and smoke stability
This commit is contained in:
@@ -4,7 +4,7 @@ import (
|
||||
"github.com/didip/tollbooth"
|
||||
"github.com/didip/tollbooth/limiter"
|
||||
"github.com/gin-gonic/gin"
|
||||
"hy2xs-admin/model/vo"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
var limit *limiter.Limiter
|
||||
@@ -17,8 +17,12 @@ 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()
|
||||
c.AbortWithStatusJSON(http.StatusTooManyRequests, gin.H{
|
||||
"code": http.StatusTooManyRequests,
|
||||
"type": "no",
|
||||
"message": "click too fast",
|
||||
"data": nil,
|
||||
})
|
||||
return
|
||||
}
|
||||
c.Next()
|
||||
|
||||
Reference in New Issue
Block a user