mirror of
https://github.com/httpjamesm/AnonymousOverflow.git
synced 2024-12-06 19:16:43 +01:00
feat: don't count static toward ratelimit
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user