mirror of
https://github.com/httpjamesm/AnonymousOverflow.git
synced 2025-04-21 06:19:14 +00:00
feat: DISABLE_RATELIMIT env
This commit is contained in:
parent
487a62e7aa
commit
6b77c5dae4
2 changed files with 7 additions and 1 deletions
|
@ -1,3 +1,3 @@
|
||||||
package config
|
package config
|
||||||
|
|
||||||
var Version = "1.8"
|
var Version = "1.8.1"
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Add table
Reference in a new issue