Skip to content

Commit

Permalink
request body updated
Browse files Browse the repository at this point in the history
  • Loading branch information
muzamil-apy committed Sep 19, 2023
1 parent 987df74 commit 443c650
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ func Logging(serviceName string) mux.MiddlewareFunc {
http.Error(w, "Failed to read request Body", http.StatusInternalServerError)
return
}
} else {
customRW.LogData.Request.Body = []byte(UnknownContentType)
}
customRW.LogData.URL = r.URL.Path
traceId := uuid.New()
Expand Down Expand Up @@ -108,7 +110,7 @@ func (rq *requestData) formatLog() string {
}
if len(rq.Body) > 0 {
// not converting r.Body to json because we're not sure what the body will be
if !isJson(rq.Headers["Content-Type"][0]) {
if rq.Headers["Content-Type"] == nil || !isJson(rq.Headers["Content-Type"][0]) {
logString = append(logString, getLogPart(`"body"`, getQuotedOrJson(rq.Body)))
} else {
var requestBody map[string]interface{}
Expand Down

0 comments on commit 443c650

Please sign in to comment.