mirror of https://github.com/markbates/pkger.git
Merge pull request #101 from requaos/requaos/gzip
Apply hepa filters before gzip'ing content
This commit is contained in:
commit
d84a13e7c2
|
@ -31,6 +31,15 @@ func Decode(src []byte) ([]byte, error) {
|
|||
}
|
||||
|
||||
func Encode(b []byte) ([]byte, error) {
|
||||
hep := hepa.New()
|
||||
hep = hepa.With(hep, filters.Home())
|
||||
hep = hepa.With(hep, filters.Golang())
|
||||
|
||||
b, err := hep.Filter(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
bb := &bytes.Buffer{}
|
||||
gz := gzip.NewWriter(bb)
|
||||
|
||||
|
@ -46,16 +55,7 @@ func Encode(b []byte) ([]byte, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
hep := hepa.New()
|
||||
hep = hepa.With(hep, filters.Home())
|
||||
hep = hepa.With(hep, filters.Golang())
|
||||
|
||||
b, err := hep.Filter(bb.Bytes())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
s := hex.EncodeToString(b)
|
||||
s := hex.EncodeToString(bb.Bytes())
|
||||
return []byte(s), nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue