2015-02-11 01:25:40 +00:00
|
|
|
package handlers
|
2015-01-06 18:37:27 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
})
|
|
|
|
}
|