Repository navigation
What's New
Sensitive Field Masking
Added support for masking sensitive fields in request/response body logs using regex patterns.
Usage:
r.Use(tlog.GinMiddleware(
tlog.WithMaskPatterns(
`(?i)password`, // matches "password", "Password", "PASSWORD"
`(?i)secret`, // matches "secret", "Secret", etc.
`(?i)token`, // matches "token", "accessToken", etc.
`(?i)api[_-]?key`, // matches "api_key", "apiKey", "API-KEY"
),
))Features:
- Regex patterns for flexible field name matching
- Recursively masks nested objects and arrays
- Only applies to JSON bodies (non-JSON unchanged)
- No performance impact when no patterns configured
- Applied to both request and response bodies
Example:
// Before
{"username": "john", "password": "secret123", "data": {"api_key": "xyz"}}
// After (logged)
{"username": "john", "password": "******", "data": {"api_key": "******"}}Commits
- feat: add sensitive field masking support for request/response bodies
- docs: add sensitive field masking documentation