1
0
mirror of https://github.com/distribution/distribution synced 2025-02-23 06:49:36 +01:00
distribution/registry/handlers/helpers.go

18 lines
383 B
Go
Raw Normal View History

package handlers
import (
"io"
"net/http"
)
// closeResources closes all the provided resources after running the target
// handler.
func closeResources(handler http.Handler, closers ...io.Closer) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
for _, closer := range closers {
defer closer.Close()
}
handler.ServeHTTP(w, r)
})
}