mirror of
https://github.com/gin-gonic/gin.git
synced 2025-04-06 03:57:46 +08:00
16 lines
239 B
Go
16 lines
239 B
Go
package main
|
|
|
|
import "github.com/gin-gonic/gin"
|
|
|
|
import "github.com/manucorporat/stats"
|
|
|
|
var ips = stats.New()
|
|
|
|
func ratelimit(c *gin.Context) {
|
|
ip := c.ClientIP()
|
|
value := ips.Add(ip, 1)
|
|
if value > 1000 {
|
|
c.AbortWithStatus(401)
|
|
}
|
|
}
|