create project

This commit is contained in:
2026-01-16 17:30:40 +08:00
commit effac6b017
157 changed files with 45997 additions and 0 deletions

30
api/middlewares/logger.go Normal file
View File

@@ -0,0 +1,30 @@
package middlewares
import (
"time"
"github.com/drama-generator/backend/pkg/logger"
"github.com/gin-gonic/gin"
)
func LoggerMiddleware(log *logger.Logger) gin.HandlerFunc {
return func(c *gin.Context) {
start := time.Now()
path := c.Request.URL.Path
query := c.Request.URL.RawQuery
c.Next()
duration := time.Since(start)
log.Infow("HTTP Request",
"method", c.Request.Method,
"path", path,
"query", query,
"status", c.Writer.Status(),
"duration", duration.Milliseconds(),
"ip", c.ClientIP(),
"user_agent", c.Request.UserAgent(),
)
}
}