Skip to content

Commit

Permalink
Switch to klauspost/compress (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxim Pugachev authored Jun 2, 2022
1 parent 502e570 commit 9c6d50f
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 23 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 4 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand All @@ -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=
Expand Down
3 changes: 1 addition & 2 deletions gzip.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package gzip

import (
"compress/gzip"

"github.com/gin-gonic/gin"
"github.com/klauspost/compress/gzip"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion gzip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package gzip

import (
"bytes"
"compress/gzip"
"context"
"fmt"
"io/ioutil"
Expand All @@ -15,6 +14,7 @@ import (
"testing"

"github.com/gin-gonic/gin"
"github.com/klauspost/compress/gzip"
"github.com/stretchr/testify/assert"
)

Expand Down
6 changes: 4 additions & 2 deletions handler.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package gzip

import (
"compress/gzip"
"fmt"
"io/ioutil"
"net/http"
Expand All @@ -10,6 +9,7 @@ import (
"sync"

"github.com/gin-gonic/gin"
"github.com/klauspost/compress/gzip"
)

type gzipHandler struct {
Expand Down Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion options.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package gzip

import (
"compress/gzip"
"net/http"
"regexp"
"strings"

"github.com/gin-gonic/gin"
"github.com/klauspost/compress/gzip"
)

var (
Expand Down

0 comments on commit 9c6d50f

Please sign in to comment.