diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 4c04167..021a348 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -27,7 +27,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - go: [1.14, 1.15, 1.16, 1.17, 1.18] + go: [1.17, 1.18] include: - os: ubuntu-latest go-build: ~/.cache/go-build diff --git a/go.mod b/go.mod index 971d5b1..fc3712a 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,28 @@ module github.com/gin-contrib/gzip require ( github.com/gin-gonic/gin v1.7.7 - github.com/stretchr/testify v1.7.0 + github.com/klauspost/compress v1.15.5 + github.com/stretchr/testify v1.7.1 ) -go 1.13 +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/gin-contrib/sse v0.1.0 // indirect + github.com/go-playground/locales v0.13.0 // indirect + github.com/go-playground/universal-translator v0.17.0 // indirect + github.com/go-playground/validator/v10 v10.4.1 // indirect + github.com/golang/protobuf v1.3.3 // indirect + github.com/json-iterator/go v1.1.9 // indirect + github.com/leodido/go-urn v1.2.0 // indirect + github.com/mattn/go-isatty v0.0.12 // indirect + github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect + github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/ugorji/go/codec v1.1.7 // indirect + golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 // indirect + golang.org/x/sys v0.0.0-20200116001909-b77594299b42 // indirect + gopkg.in/yaml.v2 v2.2.8 // indirect + gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect +) + +go 1.18 diff --git a/go.sum b/go.sum index 9ffceae..6e7257d 100644 --- a/go.sum +++ b/go.sum @@ -18,6 +18,8 @@ github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaW github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/klauspost/compress v1.15.5 h1:qyCLMz2JCrKADihKOh9FxnW3houKeNsp2h5OEz0QSEA= +github.com/klauspost/compress v1.15.5/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= @@ -31,9 +33,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo= +github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs= github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= diff --git a/gzip.go b/gzip.go index 529c62d..dce7e97 100644 --- a/gzip.go +++ b/gzip.go @@ -1,9 +1,8 @@ package gzip import ( - "compress/gzip" - "github.com/gin-gonic/gin" + "github.com/klauspost/compress/gzip" ) const ( diff --git a/gzip_test.go b/gzip_test.go index 25d6730..8cbd244 100644 --- a/gzip_test.go +++ b/gzip_test.go @@ -2,7 +2,6 @@ package gzip import ( "bytes" - "compress/gzip" "context" "fmt" "io/ioutil" @@ -15,6 +14,7 @@ import ( "testing" "github.com/gin-gonic/gin" + "github.com/klauspost/compress/gzip" "github.com/stretchr/testify/assert" ) diff --git a/handler.go b/handler.go index 8528472..d28f070 100644 --- a/handler.go +++ b/handler.go @@ -1,7 +1,6 @@ package gzip import ( - "compress/gzip" "fmt" "io/ioutil" "net/http" @@ -10,6 +9,7 @@ import ( "sync" "github.com/gin-gonic/gin" + "github.com/klauspost/compress/gzip" ) type gzipHandler struct { @@ -78,5 +78,7 @@ func (g *gzipHandler) shouldCompress(req *http.Request) bool { func (g *gzipHandler) isPathExcluded(path string) bool { extension := filepath.Ext(path) - return g.ExcludedExtensions.Contains(extension) || g.ExcludedPaths.Contains(path) || g.ExcludedPathesRegexs.Contains(path) + return g.ExcludedExtensions.Contains(extension) || + g.ExcludedPaths.Contains(path) || + g.ExcludedPathesRegexs.Contains(path) } diff --git a/options.go b/options.go index 7baa435..d154b24 100644 --- a/options.go +++ b/options.go @@ -1,12 +1,12 @@ package gzip import ( - "compress/gzip" "net/http" "regexp" "strings" "github.com/gin-gonic/gin" + "github.com/klauspost/compress/gzip" ) var (