mirror of
https://github.com/cupcakearmy/codecrafters-http-server-go.git
synced 2024-09-19 18:54:45 +02:00
21 lines
356 B
Go
21 lines
356 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"bytes"
|
||
|
"compress/gzip"
|
||
|
)
|
||
|
|
||
|
func gzipCompress(data []byte) *bytes.Buffer {
|
||
|
buf := &bytes.Buffer{}
|
||
|
gz := gzip.NewWriter(buf)
|
||
|
if _, err := gz.Write(data); err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
if err := gz.Close(); err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
|
||
|
// fmt.Println("Hexadecimal Representation:", hex.EncodeToString(buf.Bytes()))
|
||
|
return buf
|
||
|
}
|