mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[performance] wrap httpclient response body to ensure drained before close (#1854)
Signed-off-by: kim <grufwub@gmail.com>
This commit is contained in:
8
vendor/codeberg.org/gruf/go-iotools/close.go
generated
vendored
8
vendor/codeberg.org/gruf/go-iotools/close.go
generated
vendored
@@ -17,6 +17,14 @@ func CloserCallback(c io.Closer, cb func()) io.Closer {
|
||||
})
|
||||
}
|
||||
|
||||
func CloserAfterCallback(c io.Closer, cb func()) io.Closer {
|
||||
return CloserFunc(func() (err error) {
|
||||
defer func() { err = c.Close() }()
|
||||
cb()
|
||||
return
|
||||
})
|
||||
}
|
||||
|
||||
// CloseOnce wraps an io.Closer to ensure it only performs the close logic once.
|
||||
func CloseOnce(c io.Closer) io.Closer {
|
||||
return CloserFunc(func() error {
|
||||
|
Reference in New Issue
Block a user