Skip to content

Commit

Permalink
Merge pull request #18 from spotlibs/fix/middleware-activity-monitor-…
Browse files Browse the repository at this point in the history
…called-multiple-times-in-windows

fix: check nil on response body middleware activity monitor
  • Loading branch information
mdanialr authored Oct 1, 2024
2 parents 8933031 + bf0b665 commit 4800830
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 4800830

Please sign in to comment.