commento/api/utils_gzip.go
2018-06-11 15:02:14 +05:30

19 lines
261 B
Go

package main
import (
"bytes"
"compress/gzip"
)
func gzipStatic(b []byte) ([]byte, error) {
var buf bytes.Buffer
g := gzip.NewWriter(&buf)
if _, err := g.Write(b); err != nil {
g.Close()
return []byte{}, err
}
g.Close()
return buf.Bytes(), nil
}