Skip to content

Commit

Permalink
fix: set header from cache instead of add (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyahui committed Sep 14, 2021
1 parent 3889a49 commit 36a138f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
3 changes: 2 additions & 1 deletion cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,10 @@ func replyWithCache(
respCache *responseCache,
) {
c.Writer.WriteHeader(respCache.Status)

for key, values := range respCache.Header {
for _, val := range values {
c.Writer.Header().Add(key, val)
c.Writer.Header().Set(key, val)
}
}

Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ require (
github.com/go-redis/redis/v8 v8.10.0
github.com/stretchr/testify v1.7.0
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)
3 changes: 1 addition & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,5 @@ gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
4 changes: 2 additions & 2 deletions option.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ func WithCacheStrategyByRequest(getGetCacheStrategyByRequest GetCacheStrategyByR

type OnHitCacheCallback func(c *gin.Context)

func WithOnHitCache(cb OnHitCacheCallback) Option{
func WithOnHitCache(cb OnHitCacheCallback) Option {
return func(c *Config) {
if cb != nil {
c.hitCacheCallback = cb
}
}
}

var defaultHitCacheCallback = func(c *gin.Context){}
var defaultHitCacheCallback = func(c *gin.Context) {}

type Logger interface {
Errorf(string, ...interface{})
Expand Down

0 comments on commit 36a138f

Please sign in to comment.