commento/api/utils_gzip.go

19 lines
261 B
Go
Raw Permalink Normal View History

2018-06-11 17:31:58 +08:00
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
}