refactor: update audit middleware to use flattened audit package
This commit is contained in:
@@ -5,14 +5,13 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"mal/internal/auditctx"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func ContextMiddleware() gin.HandlerFunc {
|
func ContextMiddleware() gin.HandlerFunc {
|
||||||
return func(c *gin.Context) {
|
return func(c *gin.Context) {
|
||||||
ip := clientIP(c.ClientIP())
|
ip := clientIP(c.ClientIP())
|
||||||
userAgent := strings.TrimSpace(c.GetHeader("User-Agent"))
|
userAgent := strings.TrimSpace(c.GetHeader("User-Agent"))
|
||||||
c.Request = c.Request.WithContext(auditctx.WithRequestInfo(c.Request.Context(), ip, userAgent))
|
c.Request = c.Request.WithContext(WithRequestInfo(c.Request.Context(), ip, userAgent))
|
||||||
c.Next()
|
c.Next()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user