yanlongqi 805c4597af 将Web框架迁移到Gin
- 安装Gin框架 v1.11.0
- 重构main.go使用Gin路由器
- 更新handlers使用gin.Context
- 重构middleware使用Gin中间件模式
- 更新项目文档(README.md, CLAUDE.md)

项目现已准备好进行数据库集成和前端集成

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-03 11:48:39 +08:00

31 lines
449 B
Go

package middleware
import (
"log"
"time"
"github.com/gin-gonic/gin"
)
// Logger 日志中间件
func Logger() gin.HandlerFunc {
return func(c *gin.Context) {
start := time.Now()
// 处理请求
c.Next()
// 记录请求信息
duration := time.Since(start)
log.Printf(
"[%s] %s %s | %d | %v | %s",
c.Request.Method,
c.Request.RequestURI,
c.ClientIP(),
c.Writer.Status(),
duration,
c.Errors.String(),
)
}
}