Skip to content

Commit

Permalink
feat: decompress incoming gzip-encoded requests
Browse files Browse the repository at this point in the history
  • Loading branch information
yzqzss committed May 27, 2024
1 parent 7063002 commit 1a77194
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/saveweb/solar_tracker
go 1.22.2

require (
github.com/gin-contrib/gzip v1.0.1
github.com/gin-gonic/gin v1.10.0
go.mongodb.org/mongo-driver v1.15.0
)
Expand Down Expand Up @@ -43,3 +44,5 @@ require (
google.golang.org/protobuf v1.34.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/gin-contrib/gzip => github.com/yzqzss/gzip v1.0.1-onlydecompress2
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gi
github.com/youmark/pkcs8 v0.0.0-20240424034433-3c2c7870ae76 h1:tBiBTKHnIjovYoLX/TPkcf+OjqqKGQrPtGT3Foz+Pgo=
github.com/youmark/pkcs8 v0.0.0-20240424034433-3c2c7870ae76/go.mod h1:SQliXeA7Dhkt//vS29v3zpbEwoa+zb2Cn5xj5uO4K5U=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/yzqzss/gzip v1.0.1-onlydecompress2 h1:ObJHecBal2wUaMRJmovPSjxDtwrV2eW2sZuTvVHWlxM=
github.com/yzqzss/gzip v1.0.1-onlydecompress2/go.mod h1:znUGDPjZK2wf3fUHnTytpUG1GYTN7+QyrdP0RJIebKc=
go.mongodb.org/mongo-driver v1.15.0 h1:rJCKC8eEliewXjZGf0ddURtl7tTVy1TK3bfl0gkUSLc=
go.mongodb.org/mongo-driver v1.15.0/go.mod h1:Vzb0Mk/pa7e6cWw85R4F/endUC3u0U9jGcNU603k65c=
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
Expand Down
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"os"

"github.com/gin-contrib/gzip"
"github.com/gin-gonic/gin"

"go.mongodb.org/mongo-driver/mongo"
Expand Down Expand Up @@ -39,6 +40,7 @@ func init() {
}
func main() {
r := gin.Default()
r.Use(gzip.Gzip(gzip.NoCompression, gzip.WithOnlyDecompress(true), gzip.WithDecompressFn(gzip.DefaultDecompressHandle)))

r.GET("/ping", ping)
r.HEAD("/ping", ping)
Expand Down

0 comments on commit 1a77194

Please sign in to comment.