1
mirror of https://gitlab.com/commento/commento.git synced 2025-06-29 22:56:37 -04:00

api: allow gzipped response

This commit is contained in:
Adhityaa
2018-06-11 15:01:58 +05:30
parent 9e682a964a
commit 78384073b0
4 changed files with 46 additions and 6 deletions

18
api/utils_gzip.go Normal file
View File

@ -0,0 +1,18 @@
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
}