Skip to content

Commit

Permalink
defer f
Browse files Browse the repository at this point in the history
  • Loading branch information
dillonstreator committed Nov 21, 2023
1 parent c1cdcd2 commit 412c011
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions hlog/hlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,14 +343,16 @@ func AccessHandlerWithData(f func(data AccessHandlerData)) func(next http.Handle
body := mutil.NewByteCountReadCloser(r.Body)
r.Body = body

defer func() {
f(AccessHandlerData{
Request: r,
Duration: time.Since(start),
Status: ww.Status(),
BytesWritten: ww.BytesWritten(),
BytesRead: body.BytesRead(),
})
}()
next.ServeHTTP(ww, r)
f(AccessHandlerData{
Request: r,
Duration: time.Since(start),
Status: ww.Status(),
BytesWritten: ww.BytesWritten(),
BytesRead: body.BytesRead(),
})
})
}
}

0 comments on commit 412c011

Please sign in to comment.