mirror of
https://github.com/imgproxy/imgproxy.git
synced 2024-11-24 08:12:38 +02:00
25 lines
364 B
Go
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()
|
|
}
|