Automated Action 887703b6a2 Add Go Todo App implementation
This commit adds a complete Go implementation of the Todo application. The
application uses Gin framework for the web server, GORM for database access,
and SQLite for storage.

Key features:
- Todo CRUD operations with the same API endpoints
- Health check endpoint
- Database migrations
- Tests for models, services, and API handlers
- Documentation for the API
- Configurable settings
2025-05-17 22:20:05 +00:00

27 lines
673 B
Go

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())
}