2023-11-03 23:48:50 +00:00
|
|
|
package aid
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/gofiber/fiber/v2"
|
2023-12-10 00:52:59 +00:00
|
|
|
"github.com/gofiber/fiber/v2/middleware/cors"
|
2023-11-03 23:48:50 +00:00
|
|
|
"github.com/gofiber/fiber/v2/middleware/limiter"
|
|
|
|
"github.com/gofiber/fiber/v2/middleware/logger"
|
|
|
|
)
|
|
|
|
|
|
|
|
func FiberLogger() fiber.Handler {
|
|
|
|
return logger.New(logger.Config{
|
2023-11-05 22:08:53 +00:00
|
|
|
Format: "(${method}) (${status}) (${latency}) ${path}\n",
|
2023-11-03 23:48:50 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func FiberLimiter() fiber.Handler {
|
|
|
|
return limiter.New(limiter.Config{
|
|
|
|
Max: 100,
|
|
|
|
Expiration: 1 * time.Minute,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func FiberCors() fiber.Handler {
|
2023-12-10 00:52:59 +00:00
|
|
|
return cors.New(cors.Config{
|
|
|
|
AllowOrigins: "*",
|
|
|
|
AllowHeaders: "Origin, Content-Type, Accept, Authorization, X-Requested-With",
|
|
|
|
})
|
2023-11-03 23:48:50 +00:00
|
|
|
}
|