package api import ( "time" "github.com/gin-contrib/cors" "github.com/gin-gonic/gin" ) // SetupMiddleware configures middleware for the router func SetupMiddleware(router *gin.Engine) { // CORS middleware router.Use(cors.New(cors.Config{ AllowOrigins: []string{"*"}, AllowMethods: []string{"GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"}, AllowHeaders: []string{"Origin", "Content-Type", "Accept", "Authorization"}, ExposeHeaders: []string{"Content-Length"}, AllowCredentials: true, MaxAge: 12 * time.Hour, })) // Request logging middleware router.Use(gin.Logger()) // Recovery middleware router.Use(gin.Recovery()) }