Update repair; fix minor bugs with namings

This commit is contained in:
Mukhtar Akere
2025-03-21 04:10:16 +01:00
parent 0c68364a6a
commit 8d494fc277
21 changed files with 455 additions and 151 deletions

View File

@@ -2,6 +2,7 @@ package request
import (
"bytes"
"compress/gzip"
"context"
"crypto/tls"
"fmt"
@@ -288,3 +289,21 @@ func JSONResponse(w http.ResponseWriter, data interface{}, code int) {
return
}
}
func Gzip(body []byte) []byte {
var b bytes.Buffer
if len(body) == 0 {
return nil
}
gz := gzip.NewWriter(&b)
_, err := gz.Write(body)
if err != nil {
return nil
}
err = gz.Close()
if err != nil {
return nil
}
return b.Bytes()
}