summaryrefslogtreecommitdiff
path: root/vendor/codeberg.org
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2023-06-02 09:34:52 +0100
committerLibravatar GitHub <noreply@github.com>2023-06-02 10:34:52 +0200
commit20978b1278648c70e4fbeb8ebaf216f3b743519d (patch)
tree080dc8811cbf80b501d77120b5178759c53b1174 /vendor/codeberg.org
parent[chore]: Bump github.com/gin-gonic/gin from 1.9.0 to 1.9.1 (#1855) (diff)
downloadgotosocial-20978b1278648c70e4fbeb8ebaf216f3b743519d.tar.xz
[performance] wrap httpclient response body to ensure drained before close (#1854)
Signed-off-by: kim <grufwub@gmail.com>
Diffstat (limited to 'vendor/codeberg.org')
-rw-r--r--vendor/codeberg.org/gruf/go-iotools/close.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/vendor/codeberg.org/gruf/go-iotools/close.go b/vendor/codeberg.org/gruf/go-iotools/close.go
index fbed7f33c..3f0ee7780 100644
--- a/vendor/codeberg.org/gruf/go-iotools/close.go
+++ b/vendor/codeberg.org/gruf/go-iotools/close.go
@@ -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 {