1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2024-11-24 08:12:38 +02:00
imgproxy/gzip.go
2018-10-05 21:17:36 +06:00

25 lines
364 B
Go

package main
import (
"compress/gzip"
"io"
"os"
"sync"
)
var nullwriter, _ = os.Open("/dev/null")
var gzipPool = sync.Pool{
New: func() interface{} {
gz, _ := gzip.NewWriterLevel(nullwriter, conf.GZipCompression)
return gz
},
}
func gzipData(data []byte, w io.Writer) {
gz := gzipPool.Get().(*gzip.Writer)
gz.Reset(w)
gz.Write(data)
gz.Close()
}