mirror of
https://github.com/yanislav-igonin/micrach
synced 2025-04-20 03:40:33 +03:00
add rate limiter
This commit is contained in:
parent
37a788e29b
commit
a94edd70d5
18
main.go
18
main.go
@ -2,17 +2,20 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
_ "github.com/joho/godotenv/autoload"
|
||||||
|
|
||||||
|
"github.com/gofiber/fiber/v2"
|
||||||
|
"github.com/gofiber/fiber/v2/middleware/limiter"
|
||||||
|
"github.com/gofiber/template/html"
|
||||||
|
|
||||||
"micrach/build"
|
"micrach/build"
|
||||||
"micrach/config"
|
"micrach/config"
|
||||||
"micrach/db"
|
"micrach/db"
|
||||||
"micrach/repositories"
|
"micrach/repositories"
|
||||||
"micrach/templates"
|
"micrach/templates"
|
||||||
"micrach/utils"
|
"micrach/utils"
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"github.com/gofiber/fiber/v2"
|
|
||||||
"github.com/gofiber/template/html"
|
|
||||||
_ "github.com/joho/godotenv/autoload"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// import (
|
// import (
|
||||||
@ -120,6 +123,11 @@ func main() {
|
|||||||
app := fiber.New(fiber.Config{
|
app := fiber.New(fiber.Config{
|
||||||
Views: engine,
|
Views: engine,
|
||||||
})
|
})
|
||||||
|
app.Use(limiter.New(limiter.Config{
|
||||||
|
Next: func(c *fiber.Ctx) bool {
|
||||||
|
return c.IP() == "127.0.0.1"
|
||||||
|
},
|
||||||
|
}))
|
||||||
app.Static("/uploads", "./uploads")
|
app.Static("/uploads", "./uploads")
|
||||||
app.Static("/static", "./static")
|
app.Static("/static", "./static")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user