Files
go-away/lib/poison.go
2025-04-06 01:46:18 +02:00

27 lines
548 B
Go

package lib
import (
"git.gammaspectra.live/git/go-away/embed"
"io"
"path"
"slices"
"strings"
)
var poisonEncodings = []string{"br", "zstd", "gzip"}
func (state *State) getPoison(mime string, encodings []string) (r io.ReadCloser, encoding string) {
for _, encoding = range poisonEncodings {
if !slices.Contains(encodings, encoding) {
continue
}
p := path.Join("poison", strings.ReplaceAll(mime, "/", "_")+"."+encoding+".poison")
f, err := embed.PoisonFs.Open(p)
if err == nil {
return f, encoding
}
}
return nil, ""
}