mirror of
https://github.com/yusing/godoxy.git
synced 2025-05-20 20:52:33 +02:00
fixed json access logger
This commit is contained in:
parent
f683ab64ab
commit
783b352e3b
2 changed files with 6 additions and 1 deletions
|
@ -41,7 +41,7 @@ func processMap[V any](cfg *FieldConfig, m map[string]V, redactedV V) map[string
|
|||
return m
|
||||
}
|
||||
|
||||
newMap := make(map[string]V)
|
||||
newMap := make(map[string]V, len(m))
|
||||
for k := range m {
|
||||
var mode FieldMode
|
||||
var ok bool
|
||||
|
|
|
@ -123,6 +123,11 @@ func (f JSONFormatter) Format(line *bytes.Buffer, req *http.Request, res *http.R
|
|||
entry.Error = res.Status
|
||||
}
|
||||
|
||||
if entry.ContentType != "" {
|
||||
// try to get content type from request
|
||||
entry.ContentType = req.Header.Get("Content-Type")
|
||||
}
|
||||
|
||||
marshaller := json.NewEncoder(line)
|
||||
err := marshaller.Encode(entry)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Reference in a new issue