Skip to content

Commit

Permalink
refactor: migrate to io package for improved compatibility
Browse files Browse the repository at this point in the history
- Replace ioutil package with io package for better compatibility
- Update gzip handler to use the new io package methods

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
  • Loading branch information
appleboy committed Aug 24, 2024
1 parent a6b2037 commit 4766b70
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package gzip
import (
"compress/gzip"
"fmt"
"io/ioutil"
"io"
"net/http"
"path/filepath"
"strings"
Expand All @@ -22,7 +22,7 @@ func newGzipHandler(level int, options ...Option) *gzipHandler {
Options: DefaultOptions,
gzPool: sync.Pool{
New: func() interface{} {
gz, err := gzip.NewWriterLevel(ioutil.Discard, level)
gz, err := gzip.NewWriterLevel(io.Discard, level)
if err != nil {
panic(err)
}
Expand All @@ -47,7 +47,7 @@ func (g *gzipHandler) Handle(c *gin.Context) {

gz := g.gzPool.Get().(*gzip.Writer)
defer g.gzPool.Put(gz)
defer gz.Reset(ioutil.Discard)
defer gz.Reset(io.Discard)
gz.Reset(c.Writer)

c.Header("Content-Encoding", "gzip")
Expand Down

0 comments on commit 4766b70

Please sign in to comment.