feat: DISABLE_RATELIMIT env

This commit is contained in:
httpjamesm 2023-02-25 12:39:09 -05:00
parent 487a62e7aa
commit 6b77c5dae4
No known key found for this signature in database
2 changed files with 7 additions and 1 deletions

View File

@ -1,3 +1,3 @@
package config package config
var Version = "1.8" var Version = "1.8.1"

View File

@ -2,6 +2,7 @@ package middleware
import ( import (
"anonymousoverflow/config" "anonymousoverflow/config"
"os"
"strings" "strings"
"sync" "sync"
"time" "time"
@ -14,6 +15,11 @@ var ipMap = sync.Map{}
func Ratelimit() gin.HandlerFunc { func Ratelimit() gin.HandlerFunc {
return func(c *gin.Context) { return func(c *gin.Context) {
if os.Getenv("DISABLE_RATELIMIT") == "true" {
c.Next()
return
}
if strings.HasPrefix(c.Request.URL.Path, "/static") { if strings.HasPrefix(c.Request.URL.Path, "/static") {
c.Next() c.Next()
return return