fix: close Body correctly

This commit is contained in:
Oleh Astappiev 2024-12-08 20:55:06 +01:00
parent 02580cce20
commit 254effa8e5
No known key found for this signature in database
GPG key ID: 37D7AC22589E9632
2 changed files with 6 additions and 3 deletions

View file

@ -120,11 +120,11 @@ func (h *UmamiFeeder) reportEventToUmami(ctx context.Context, event *UmamiPayloa
h.debug("sending tracking request %s with body %v %v", event.body.Payload.Url, event.body, event.headers)
resp, err := sendRequest(ctx, h.umamiHost+"/api/send", event.body, event.headers)
defer func() {
_ = resp.Body.Close()
}()
if err != nil {
h.error("failed to send tracking: " + err.Error())
return
}
defer func() {
_ = resp.Body.Close()
}()
}