mirror of
https://github.com/yanislav-igonin/micrach
synced 2024-12-22 22:32:33 +03:00
feat: turn rate limiter back on
This commit is contained in:
parent
2d321e8833
commit
0cc994c2b7
18
main.go
18
main.go
@ -3,17 +3,16 @@ package main
|
|||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
_ "github.com/joho/godotenv/autoload"
|
_ "github.com/joho/godotenv/autoload"
|
||||||
|
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
"github.com/gofiber/fiber/v2/middleware/compress"
|
"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/fiber/v2/middleware/recover"
|
||||||
"github.com/gofiber/template/html"
|
"github.com/gofiber/template/html"
|
||||||
|
|
||||||
// "github.com/gofiber/fiber/v2/middleware/limiter"
|
|
||||||
|
|
||||||
"micrach/build"
|
"micrach/build"
|
||||||
"micrach/config"
|
"micrach/config"
|
||||||
"micrach/controllers"
|
"micrach/controllers"
|
||||||
@ -50,11 +49,16 @@ func main() {
|
|||||||
app := fiber.New(fiber.Config{Views: engine})
|
app := fiber.New(fiber.Config{Views: engine})
|
||||||
|
|
||||||
app.Use(recover.New())
|
app.Use(recover.New())
|
||||||
// app.Use(limiter.New(limiter.Config{
|
app.Use(limiter.New(limiter.Config{
|
||||||
// Next: func(c *fiber.Ctx) bool { return c.IsFromLocal() },
|
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(compress.New())
|
||||||
app.Use(etag.New())
|
|
||||||
|
|
||||||
app.Static("/uploads", "./uploads")
|
app.Static("/uploads", "./uploads")
|
||||||
app.Static("/static", "./static")
|
app.Static("/static", "./static")
|
||||||
|
Loading…
Reference in New Issue
Block a user