This commit is contained in:
Mike Schwörer 2023-08-09 19:51:41 +02:00
parent f0881c9fd6
commit 0da098e9f9
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
2 changed files with 17 additions and 3 deletions

View File

@ -306,7 +306,7 @@ func (b *Builder) GinReq(ctx context.Context, g *gin.Context, req *http.Request)
}
b.Str("gin.method", req.Method)
b.Str("gin.path", g.FullPath())
b.Str("gin.header", formatHeader(g.Request.Header))
b.Strs("gin.header", extractHeader(g.Request.Header))
if req.URL != nil {
b.Str("gin.url", req.URL.String())
}
@ -367,6 +367,20 @@ func formatHeader(header map[string][]string) string {
return r
}
func extractHeader(header map[string][]string) []string {
r := make([]string, 0, len(header))
for k, v := range header {
for _, hval := range v {
value := hval
value = strings.ReplaceAll(value, "\n", "\\n")
value = strings.ReplaceAll(value, "\r", "\\r")
value = strings.ReplaceAll(value, "\t", "\\t")
r = append(r, k+": "+value)
}
}
return r
}
// ----------------------------------------------------------------------------
// Build creates a new error, ready to pass up the stack

View File

@ -1,5 +1,5 @@
package goext
const GoextVersion = "0.0.237"
const GoextVersion = "0.0.238"
const GoextVersionTimestamp = "2023-08-09T19:35:01+0200"
const GoextVersionTimestamp = "2023-08-09T19:51:41+0200"