Skip to content

Commit

Permalink
fix(chore): request body consumed (#322)
Browse files Browse the repository at this point in the history
* fix(chore): request body consumed

* fix: use ioutil in the graphql tyk override

* feat: bump souin version
  • Loading branch information
darkweak committed Mar 12, 2023
1 parent ca16a57 commit 8d6d13f
Show file tree
Hide file tree
Showing 21 changed files with 37 additions and 32 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ experimental:
plugins:
souin:
moduleName: github.com/darkweak/souin
version: v1.6.33
version: v1.6.34
```
After that you can declare either the whole configuration at once in the middleware block or by service. See the examples below.
```yaml
Expand Down
1 change: 1 addition & 0 deletions context/graphql.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func (g *graphQLContext) SetContext(req *http.Request) *http.Request {
if g.custom && req.Body != nil {
b := bytes.NewBuffer([]byte{})
_, _ = io.Copy(b, req.Body)
req.Body = io.NopCloser(b)
if b.Len() > 0 {
if isMutation(b.Bytes()) {
ctx = context.WithValue(ctx, IsMutationRequest, true)
Expand Down
4 changes: 2 additions & 2 deletions plugins/beego/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.19

require (
github.com/beego/beego/v2 v2.0.7
github.com/darkweak/souin v1.6.33
github.com/darkweak/souin v1.6.34
)

require (
Expand Down Expand Up @@ -86,4 +86,4 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/darkweak/souin v1.6.33 => ../..
replace github.com/darkweak/souin v1.6.34 => ../..
4 changes: 2 additions & 2 deletions plugins/caddy/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.19
require (
github.com/buraksezer/olric v0.5.4
github.com/caddyserver/caddy/v2 v2.6.4
github.com/darkweak/souin v1.6.33
github.com/darkweak/souin v1.6.34
go.uber.org/zap v1.24.0
)

Expand Down Expand Up @@ -178,4 +178,4 @@ require (
howett.net/plist v1.0.0 // indirect
)

replace github.com/darkweak/souin v1.6.33 => ../..
replace github.com/darkweak/souin v1.6.34 => ../..
4 changes: 2 additions & 2 deletions plugins/chi/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/darkweak/souin/plugins/chi
go 1.19

require (
github.com/darkweak/souin v1.6.33
github.com/darkweak/souin v1.6.34
github.com/go-chi/chi/v5 v5.0.8
)

Expand Down Expand Up @@ -83,4 +83,4 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/darkweak/souin v1.6.33 => ../..
replace github.com/darkweak/souin v1.6.34 => ../..
4 changes: 2 additions & 2 deletions plugins/dotweb/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/darkweak/souin/plugins/dotweb
go 1.19

require (
github.com/darkweak/souin v1.6.33
github.com/darkweak/souin v1.6.34
github.com/devfeel/dotweb v1.7.19
)

Expand Down Expand Up @@ -84,4 +84,4 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/darkweak/souin v1.6.33 => ../..
replace github.com/darkweak/souin v1.6.34 => ../..
4 changes: 2 additions & 2 deletions plugins/echo/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/darkweak/souin/plugins/echo
go 1.19

require (
github.com/darkweak/souin v1.6.33
github.com/darkweak/souin v1.6.34
github.com/labstack/echo/v4 v4.10.2
)

Expand Down Expand Up @@ -89,4 +89,4 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/darkweak/souin v1.6.33 => ../..
replace github.com/darkweak/souin v1.6.34 => ../..
4 changes: 2 additions & 2 deletions plugins/fiber/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/darkweak/souin/plugins/fiber
go 1.19

require (
github.com/darkweak/souin v1.6.33
github.com/darkweak/souin v1.6.34
github.com/gofiber/fiber/v2 v2.42.0
github.com/valyala/fasthttp v1.44.0
)
Expand Down Expand Up @@ -95,4 +95,4 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/darkweak/souin v1.6.33 => ../..
replace github.com/darkweak/souin v1.6.34 => ../..
4 changes: 2 additions & 2 deletions plugins/gin/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/darkweak/souin/plugins/gin
go 1.19

require (
github.com/darkweak/souin v1.6.33
github.com/darkweak/souin v1.6.34
github.com/gin-gonic/gin v1.9.0
)

Expand Down Expand Up @@ -101,4 +101,4 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/darkweak/souin v1.6.33 => ../..
replace github.com/darkweak/souin v1.6.34 => ../..
4 changes: 2 additions & 2 deletions plugins/go-zero/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/darkweak/souin/plugins/go-zero
go 1.19

require (
github.com/darkweak/souin v1.6.33
github.com/darkweak/souin v1.6.34
github.com/zeromicro/go-zero v1.5.0
)

Expand Down Expand Up @@ -107,4 +107,4 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/darkweak/souin v1.6.33 => ../..
replace github.com/darkweak/souin v1.6.34 => ../..
4 changes: 2 additions & 2 deletions plugins/goyave/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/darkweak/souin/plugins/goyave
go 1.19

require (
github.com/darkweak/souin v1.6.33
github.com/darkweak/souin v1.6.34
goyave.dev/goyave/v4 v4.4.8
)

Expand Down Expand Up @@ -90,4 +90,4 @@ require (
gorm.io/gorm v1.24.6 // indirect
)

replace github.com/darkweak/souin v1.6.33 => ../..
replace github.com/darkweak/souin v1.6.34 => ../..
4 changes: 2 additions & 2 deletions plugins/kratos/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/darkweak/souin/plugins/kratos
go 1.19

require (
github.com/darkweak/souin v1.6.33
github.com/darkweak/souin v1.6.34
github.com/go-kratos/kratos/v2 v2.5.4
gopkg.in/yaml.v3 v3.0.1
)
Expand Down Expand Up @@ -86,4 +86,4 @@ require (
gopkg.in/yaml.v2 v2.4.0 // indirect
)

replace github.com/darkweak/souin v1.6.33 => ../..
replace github.com/darkweak/souin v1.6.34 => ../..
4 changes: 2 additions & 2 deletions plugins/roadrunner/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/darkweak/souin/plugins/roadrunner
go 1.19

require (
github.com/darkweak/souin v1.6.33
github.com/darkweak/souin v1.6.34
github.com/roadrunner-server/errors v1.2.0
go.uber.org/zap v1.24.0
gopkg.in/yaml.v3 v3.0.1
Expand Down Expand Up @@ -83,4 +83,4 @@ require (
gopkg.in/yaml.v2 v2.4.0 // indirect
)

replace github.com/darkweak/souin v1.6.33 => ../..
replace github.com/darkweak/souin v1.6.34 => ../..
4 changes: 2 additions & 2 deletions plugins/skipper/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/darkweak/souin/plugins/skipper
go 1.19

require (
github.com/darkweak/souin v1.6.33
github.com/darkweak/souin v1.6.34
github.com/zalando/skipper v0.13.225
)

Expand Down Expand Up @@ -127,4 +127,4 @@ require (
layeh.com/gopher-json v0.0.0-20201124131017-552bb3c4c3bf // indirect
)

replace github.com/darkweak/souin v1.6.33 => ../..
replace github.com/darkweak/souin v1.6.34 => ../..
4 changes: 2 additions & 2 deletions plugins/traefik/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/darkweak/souin/plugins/traefik
go 1.19

require (
github.com/darkweak/souin v1.6.33
github.com/darkweak/souin v1.6.34
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/pquerna/cachecontrol v0.1.0
go.uber.org/zap v1.21.0
Expand Down Expand Up @@ -85,4 +85,4 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/darkweak/souin v1.6.33 => ../..
replace github.com/darkweak/souin v1.6.34 => ../..
1 change: 1 addition & 0 deletions plugins/traefik/override/context/graphql.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func (g *graphQLContext) SetContext(req *http.Request) *http.Request {
if g.custom && req.Body != nil {
b := bytes.NewBuffer([]byte{})
_, _ = io.Copy(b, req.Body)
req.Body = io.NopCloser(b)
if b.Len() > 0 {
if isMutation(b.Bytes()) {
rq = rq.WithContext(context.WithValue(rq.Context(), IsMutationRequest, true))
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/traefik/vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ github.com/coreos/go-systemd/v22/journal
# github.com/darkweak/go-esi v0.0.5
## explicit; go 1.18
github.com/darkweak/go-esi/esi
# github.com/darkweak/souin v1.6.33 => ../..
# github.com/darkweak/souin v1.6.34 => ../..
## explicit; go 1.16
github.com/darkweak/souin/cache/providers
github.com/darkweak/souin/cache/types
Expand Down
4 changes: 2 additions & 2 deletions plugins/tyk/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.16
require (
github.com/HdrHistogram/hdrhistogram-go v1.1.2 // indirect
github.com/TykTechnologies/tyk v1.9.2-0.20220905191535-f610431668e4
github.com/darkweak/souin v1.6.33
github.com/darkweak/souin v1.6.34
github.com/eclipse/paho.mqtt.golang v1.4.1 // indirect
github.com/evanphx/json-patch/v5 v5.5.0 // indirect
github.com/gobwas/ws v1.1.0 // indirect
Expand All @@ -32,4 +32,4 @@ require (
gorm.io/gorm v1.23.9 // indirect
)

replace github.com/darkweak/souin v1.6.33 => ../..
replace github.com/darkweak/souin v1.6.34 => ../..
2 changes: 2 additions & 0 deletions plugins/tyk/override/context/graphql.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"crypto/sha256"
"fmt"
"io"
"io/ioutil"
"net/http"

"github.com/darkweak/souin/configurationtypes"
Expand Down Expand Up @@ -39,6 +40,7 @@ func (g *graphQLContext) SetContext(req *http.Request) *http.Request {
if g.custom && req.Body != nil {
b := bytes.NewBuffer([]byte{})
_, _ = io.Copy(b, req.Body)
req.Body = ioutil.NopCloser(b)
if b.Len() > 0 {
if isMutation(b.Bytes()) {
rq = rq.WithContext(context.WithValue(rq.Context(), IsMutationRequest, true))
Expand Down
4 changes: 2 additions & 2 deletions plugins/webgo/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.19

require (
github.com/bnkamalesh/webgo/v6 v6.7.0
github.com/darkweak/souin v1.6.33
github.com/darkweak/souin v1.6.34
)

require (
Expand Down Expand Up @@ -83,4 +83,4 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/darkweak/souin v1.6.33 => ../..
replace github.com/darkweak/souin v1.6.34 => ../..

0 comments on commit 8d6d13f

Please sign in to comment.