package middleware import ( "time" "github.com/gin-gonic/gin" applogger "github.com/gochat/gochat/pkg/logger" ) // RequestLogger logs structured request information. // Pattern follows Chatwoot's Rails request logging middleware. func RequestLogger() gin.HandlerFunc { return func(c *gin.Context) { start := time.Now() path := c.Request.URL.Path method := c.Request.Method c.Next() latency := time.Since(start) status := c.Writer.Status() applogger.L().Infof("HTTP %s %s %d %v", method, path, status, latency) c.Next() } }