Files
gochat/backend/internal/middleware/logger.go
T
Rogeeandrogee f719529d66 fix(security): harden auth and secret handling (HH-444) (#101)
* fix(security): harden auth and credential handling (HH-444)

* fix(security): address HH-444 review blockers

* fix(security): close remaining HH-444 review blockers

---------

Co-authored-by: Rogee <rogee@ipao.vip>
2026-08-22 15:45:06 +08:00

30 lines
604 B
Go

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()
if route := c.FullPath(); route != "" {
path = route
}
applogger.L().Infof("HTTP %s %s %d %v",
method, path, status, latency)
}
}