chore: 初始化仓库基线(AGENTS.md、git 规范、敏感文件排除)

This commit is contained in:
weijuesen
2026-08-10 22:30:53 +08:00
commit 84abf4454c
358 changed files with 75993 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
package middleware
import (
"log/slog"
"time"
"github.com/gin-gonic/gin"
)
// Logger 请求日志中间件,记录方法、路径、状态码、耗时
func Logger() gin.HandlerFunc {
return func(c *gin.Context) {
start := time.Now()
path := c.Request.URL.Path
c.Next()
latency := time.Since(start)
status := c.Writer.Status()
slog.Info("请求",
"method", c.Request.Method,
"path", path,
"status", status,
"latency", latency.String(),
"ip", c.ClientIP(),
)
}
}