Skip to content

Commit

Permalink
fix: check nil on response body middleware activity monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
mdanialr committed Oct 1, 2024
1 parent 8933031 commit bf0b665
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion middleware/activity_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ func apiActivityRecorder(c http.Context, start time.Time) {

// transform back response to an object before capturing
var res map[string]any
_ = sonic.ConfigFastest.Unmarshal(c.Response().Origin().Body().Bytes(), &res)
if v := c.Response().Origin().Body(); v != nil {
_ = sonic.ConfigFastest.Unmarshal(v.Bytes(), &res)
}

// get metadata from context
mt := ctx.Get(c)
Expand Down

0 comments on commit bf0b665

Please sign in to comment.