fix: dedup "headers" attribute
This commit is contained in:
+10
-2
@@ -177,12 +177,16 @@ func NewWithConfig(logger *slog.Logger, config Config) gin.HandlerFunc {
|
||||
|
||||
// request headers
|
||||
if config.WithRequestHeader {
|
||||
kv := []any{}
|
||||
|
||||
for k, v := range c.Request.Header {
|
||||
if _, found := HiddenRequestHeaders[strings.ToLower(k)]; found {
|
||||
continue
|
||||
}
|
||||
requestAttributes = append(requestAttributes, slog.Group("header", slog.Any(k, v)))
|
||||
kv = append(kv, slog.Any(k, v))
|
||||
}
|
||||
|
||||
requestAttributes = append(requestAttributes, slog.Group("header", kv...))
|
||||
}
|
||||
|
||||
if config.WithUserAgent {
|
||||
@@ -197,12 +201,16 @@ func NewWithConfig(logger *slog.Logger, config Config) gin.HandlerFunc {
|
||||
|
||||
// response headers
|
||||
if config.WithResponseHeader {
|
||||
kv := []any{}
|
||||
|
||||
for k, v := range c.Writer.Header() {
|
||||
if _, found := HiddenResponseHeaders[strings.ToLower(k)]; found {
|
||||
continue
|
||||
}
|
||||
responseAttributes = append(responseAttributes, slog.Group("header", slog.Any(k, v)))
|
||||
kv = append(kv, slog.Any(k, v))
|
||||
}
|
||||
|
||||
responseAttributes = append(responseAttributes, slog.Group("header", kv...))
|
||||
}
|
||||
|
||||
attributes := append(
|
||||
|
||||
Reference in New Issue
Block a user