diff --git a/main.go b/main.go index ff3fd54..9252854 100644 --- a/main.go +++ b/main.go @@ -3,17 +3,16 @@ package main import ( "log" "strconv" + "strings" _ "github.com/joho/godotenv/autoload" "github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2/middleware/compress" - "github.com/gofiber/fiber/v2/middleware/etag" + "github.com/gofiber/fiber/v2/middleware/limiter" "github.com/gofiber/fiber/v2/middleware/recover" "github.com/gofiber/template/html" - // "github.com/gofiber/fiber/v2/middleware/limiter" - "micrach/build" "micrach/config" "micrach/controllers" @@ -50,11 +49,16 @@ func main() { app := fiber.New(fiber.Config{Views: engine}) app.Use(recover.New()) - // app.Use(limiter.New(limiter.Config{ - // Next: func(c *fiber.Ctx) bool { return c.IsFromLocal() }, - // })) + app.Use(limiter.New(limiter.Config{ + Next: func(c *fiber.Ctx) bool { + isDev := c.IsFromLocal() + path := c.Path() + isRequestForStatic := strings.Contains(path, "/static") || strings.Contains(path, "/uploads") || strings.Contains(path, "/captcha") + return isRequestForStatic || isDev + }, + Max: 50, + })) app.Use(compress.New()) - app.Use(etag.New()) app.Static("/uploads", "./uploads") app.Static("/static", "./static")