feat: don't count static toward ratelimit

This commit is contained in:
httpjamesm 2023-02-20 13:56:44 -05:00
parent f1370c29b6
commit 63a30ab1cf
No known key found for this signature in database

View File

@ -2,6 +2,7 @@ package middleware
import (
"anonymousoverflow/config"
"strings"
"sync"
"time"
@ -12,6 +13,12 @@ var ipMap = sync.Map{}
func Ratelimit() gin.HandlerFunc {
return func(c *gin.Context) {
if strings.HasPrefix(c.Request.URL.Path, "/static") {
c.Next()
return
}
ip := c.ClientIP()
// log request count as the value, ip as key