snow/aid/fiber.go
eccentric 188e7dc7b0 Fixed Styled Lobbies; Fixed VBucks on early seasons; ...
Added KeyChain for newer seasons.
2023-11-05 22:08:53 +00:00

31 lines
743 B
Go

package aid
import (
"time"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/limiter"
"github.com/gofiber/fiber/v2/middleware/logger"
)
func FiberLogger() fiber.Handler {
return logger.New(logger.Config{
Format: "(${method}) (${status}) (${latency}) ${path}\n",
})
}
func FiberLimiter() fiber.Handler {
return limiter.New(limiter.Config{
Max: 100,
Expiration: 1 * time.Minute,
})
}
func FiberCors() fiber.Handler {
return func(c *fiber.Ctx) error {
c.Set("Access-Control-Allow-Origin", "*")
c.Set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS")
c.Set("Access-Control-Allow-Headers", "Content-Type, Authorization, Origin, Accept, X-Requested-With")
return c.Next()
}
}