Пример #1
0
func rateLimit(c *gin.Context) {

	ip := c.ClientIP()
	value := int(ips.Add(ip, 1))
	if value%50 == 0 {
		fmt.Printf("ip: %s, count: %d\n", ip, value)
	}
	if value >= 200 {
		if value%200 == 0 {
			fmt.Println("ip blocked")
		}
		c.Abort()
		c.String(503, "you were automatically banned :)")
	}
}
Пример #2
0
func mdFunc(c *gin.Context) {
	c.String(http.StatusOK, string(blackfriday.MarkdownBasic([]byte("**hi!**"))))
}