Skip to content

Commit

Permalink
Call AccessHandler's f also on panic.
Browse files Browse the repository at this point in the history
  • Loading branch information
mitar committed Oct 29, 2023
1 parent dfd2071 commit 1b298bf
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion hlog/hlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,10 @@ func AccessHandler(f func(r *http.Request, status, size int, duration time.Durat
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
start := time.Now()
lw := mutil.WrapWriter(w)
defer func() {
f(r, lw.Status(), lw.BytesWritten(), time.Since(start))
}()
next.ServeHTTP(lw, r)
f(r, lw.Status(), lw.BytesWritten(), time.Since(start))
})
}
}
Expand Down

0 comments on commit 1b298bf

Please sign in to comment.