mirror of
https://github.com/twofas/2fas-server.git
synced 2024-12-12 12:09:56 +01:00
25 lines
533 B
Go
25 lines
533 B
Go
package http
|
|
|
|
import (
|
|
"github.com/2fas/api/internal/common/logging"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func RequestJsonLogger() gin.HandlerFunc {
|
|
return func(c *gin.Context) {
|
|
requestLogger := logging.WithFields(logging.Fields{
|
|
"client_ip": c.ClientIP(),
|
|
"method": c.Request.Method,
|
|
"path": c.Request.URL.Path,
|
|
"request_id": c.GetString(RequestIdKey),
|
|
"correlation_id": c.GetString(CorrelationIdKey),
|
|
})
|
|
|
|
requestLogger.Info("Request")
|
|
|
|
c.Next()
|
|
|
|
requestLogger.Info("Response")
|
|
}
|
|
}
|