feat: don't count static toward ratelimit
This commit is contained in:
parent
f1370c29b6
commit
63a30ab1cf
@ -2,6 +2,7 @@ package middleware
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"anonymousoverflow/config"
|
"anonymousoverflow/config"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -12,6 +13,12 @@ var ipMap = sync.Map{}
|
|||||||
|
|
||||||
func Ratelimit() gin.HandlerFunc {
|
func Ratelimit() gin.HandlerFunc {
|
||||||
return func(c *gin.Context) {
|
return func(c *gin.Context) {
|
||||||
|
|
||||||
|
if strings.HasPrefix(c.Request.URL.Path, "/static") {
|
||||||
|
c.Next()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
ip := c.ClientIP()
|
ip := c.ClientIP()
|
||||||
|
|
||||||
// log request count as the value, ip as key
|
// log request count as the value, ip as key
|
||||||
|
Loading…
x
Reference in New Issue
Block a user