limiter changes and import changes

This commit is contained in:
Ravi Prasad
2026-05-05 23:05:29 -05:00
parent c66a2d5d06
commit 7578a69988
2 changed files with 17 additions and 7 deletions
+11 -1
View File
@@ -1,6 +1,7 @@
package middleware
import (
"strings"
"time"
"github.com/gofiber/fiber/v2"
@@ -9,8 +10,17 @@ import (
func RateLimiter() fiber.Handler {
return limiter.New(limiter.Config{
Max: 30,
Max: 20,
Expiration: 1 * time.Minute,
Next: func(c *fiber.Ctx) bool {
// Skip rate limiting for internal services and infra endpoints
ip := c.IP()
if strings.HasPrefix(ip, "10.") || strings.HasPrefix(ip, "172.") || ip == "127.0.0.1" {
return true
}
path := c.Path()
return path == "/metrics" || strings.HasPrefix(path, "/swagger")
},
KeyGenerator: func(c *fiber.Ctx) string {
if ip := c.Get("X-Real-IP"); ip != "" {
return ip