mirror of
https://github.com/woodchen-ink/proxy-go.git
synced 2025-07-18 16:41:54 +08:00
add brotli and gzip compression support, update docker-compose and deployment script
24 lines
451 B
Go
24 lines
451 B
Go
package compression
|
|
|
|
import (
|
|
"io"
|
|
|
|
"github.com/andybalholm/brotli"
|
|
)
|
|
|
|
type BrotliCompressor struct {
|
|
level int
|
|
}
|
|
|
|
func NewBrotliCompressor(level int) *BrotliCompressor {
|
|
// 确保level在有效范围内 (0-11)
|
|
if level < 0 || level > 11 {
|
|
level = brotli.DefaultCompression
|
|
}
|
|
return &BrotliCompressor{level: level}
|
|
}
|
|
|
|
func (b *BrotliCompressor) Compress(w io.Writer) (io.WriteCloser, error) {
|
|
return brotli.NewWriterLevel(w, b.level), nil
|
|
}
|