Skip to content

Commit 22abb94

Browse files
authored
fix(chore): caddy default provider check (#551)
1 parent 12a2857 commit 22abb94

File tree

23 files changed

+45
-41
lines changed

23 files changed

+45
-41
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,7 @@ experimental:
952952
plugins:
953953
souin:
954954
moduleName: github.com/darkweak/souin
955-
version: v1.7.0
955+
version: v1.7.1
956956
```
957957
After that you can declare either the whole configuration at once in the middleware block or by service. See the examples below.
958958
```yaml

plugins/beego/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ toolchain go1.22.4
66

77
require (
88
github.com/beego/beego/v2 v2.1.1
9-
github.com/darkweak/souin v1.7.0
9+
github.com/darkweak/souin v1.7.1
1010
github.com/darkweak/souin/plugins/souin v0.0.0-00010101000000-000000000000
1111
github.com/darkweak/souin/plugins/souin/storages v0.0.0-00010101000000-000000000000
1212
)
@@ -184,7 +184,7 @@ require (
184184
)
185185

186186
replace (
187-
github.com/darkweak/souin v1.7.0 => ../..
187+
github.com/darkweak/souin v1.7.1 => ../..
188188
github.com/darkweak/souin/plugins/souin => ../souin
189189
github.com/darkweak/souin/plugins/souin/storages => ../souin/storages
190190
)

plugins/caddy/dispatch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func (s *SouinCaddyMiddleware) parseStorages(ctx caddy.Context) {
121121
address := redis.URL
122122
username := ""
123123
dbname := "0"
124-
cname := ""
124+
cname := "souin-redis"
125125
if c := redis.Configuration; c != nil {
126126
p, ok := c.(map[string]interface{})
127127
if ok {

plugins/caddy/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.22.1
44

55
require (
66
github.com/caddyserver/caddy/v2 v2.8.4
7-
github.com/darkweak/souin v1.7.0
7+
github.com/darkweak/souin v1.7.1
88
github.com/darkweak/storages/core v0.0.8
99
)
1010

@@ -153,4 +153,4 @@ require (
153153
howett.net/plist v1.0.0 // indirect
154154
)
155155

156-
replace github.com/darkweak/souin v1.7.0 => ../..
156+
replace github.com/darkweak/souin v1.7.1 => ../..

plugins/caddy/httpcache.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ func (s *SouinCaddyMiddleware) configurationPropertyMapper() error {
116116
return nil
117117
}
118118

119+
func isProviderEmpty(c configurationtypes.CacheProvider) bool {
120+
return c.Configuration == nil && c.Path == "" && c.URL == ""
121+
}
122+
119123
// FromApp to initialize configuration from App structure.
120124
func (s *SouinCaddyMiddleware) FromApp(app *SouinApp) error {
121125
if s.Configuration.GetDefaultCache() == nil {
@@ -199,7 +203,7 @@ func (s *SouinCaddyMiddleware) FromApp(app *SouinApp) error {
199203
if dc.CacheName == "" {
200204
s.Configuration.DefaultCache.CacheName = appDc.CacheName
201205
}
202-
if !s.Configuration.DefaultCache.Distributed && !dc.Olric.Found && !dc.Redis.Found && !dc.Etcd.Found && !dc.Badger.Found && !dc.Nuts.Found && !dc.Otter.Found {
206+
if isProviderEmpty(dc.Badger) && isProviderEmpty(dc.Etcd) && isProviderEmpty(dc.Nats) && isProviderEmpty(dc.Nuts) && isProviderEmpty(dc.Olric) && isProviderEmpty(dc.Otter) && isProviderEmpty(dc.Redis) {
203207
s.Configuration.DefaultCache.Distributed = appDc.Distributed
204208
s.Configuration.DefaultCache.Olric = appDc.Olric
205209
s.Configuration.DefaultCache.Redis = appDc.Redis

plugins/chi/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/darkweak/souin/plugins/chi
33
go 1.22.1
44

55
require (
6-
github.com/darkweak/souin v1.7.0
6+
github.com/darkweak/souin v1.7.1
77
github.com/darkweak/souin/plugins/souin/storages v0.0.0-00010101000000-000000000000
88
github.com/go-chi/chi/v5 v5.0.12
99
)
@@ -179,6 +179,6 @@ require (
179179
)
180180

181181
replace (
182-
github.com/darkweak/souin v1.7.0 => ../..
182+
github.com/darkweak/souin v1.7.1 => ../..
183183
github.com/darkweak/souin/plugins/souin/storages => ../souin/storages
184184
)

plugins/dotweb/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/darkweak/souin/plugins/dotweb
33
go 1.22.1
44

55
require (
6-
github.com/darkweak/souin v1.7.0
6+
github.com/darkweak/souin v1.7.1
77
github.com/darkweak/souin/plugins/souin/storages v0.0.0-00010101000000-000000000000
88
github.com/devfeel/dotweb v1.7.21
99
)
@@ -180,6 +180,6 @@ require (
180180
)
181181

182182
replace (
183-
github.com/darkweak/souin v1.7.0 => ../..
183+
github.com/darkweak/souin v1.7.1 => ../..
184184
github.com/darkweak/souin/plugins/souin/storages => ../souin/storages
185185
)

plugins/echo/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/darkweak/souin/plugins/echo
33
go 1.22.1
44

55
require (
6-
github.com/darkweak/souin v1.7.0
6+
github.com/darkweak/souin v1.7.1
77
github.com/darkweak/souin/plugins/souin/storages v0.0.0-00010101000000-000000000000
88
github.com/darkweak/storages/core v0.0.8
99
github.com/labstack/echo/v4 v4.11.1
@@ -182,6 +182,6 @@ require (
182182
)
183183

184184
replace (
185-
github.com/darkweak/souin v1.7.0 => ../..
185+
github.com/darkweak/souin v1.7.1 => ../..
186186
github.com/darkweak/souin/plugins/souin/storages => ../souin/storages
187187
)

plugins/fiber/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/darkweak/souin/plugins/fiber
33
go 1.22.1
44

55
require (
6-
github.com/darkweak/souin v1.7.0
6+
github.com/darkweak/souin v1.7.1
77
github.com/darkweak/souin/plugins/souin/storages v0.0.0-00010101000000-000000000000
88
github.com/gofiber/fiber/v2 v2.52.1
99
github.com/valyala/fasthttp v1.51.0
@@ -185,6 +185,6 @@ require (
185185
)
186186

187187
replace (
188-
github.com/darkweak/souin v1.7.0 => ../..
188+
github.com/darkweak/souin v1.7.1 => ../..
189189
github.com/darkweak/souin/plugins/souin/storages => ../souin/storages
190190
)

plugins/gin/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/darkweak/souin/plugins/gin
33
go 1.22.1
44

55
require (
6-
github.com/darkweak/souin v1.7.0
6+
github.com/darkweak/souin v1.7.1
77
github.com/darkweak/souin/plugins/souin/storages v0.0.0-00010101000000-000000000000
88
github.com/gin-gonic/gin v1.9.1
99
)
@@ -196,6 +196,6 @@ require (
196196
)
197197

198198
replace (
199-
github.com/darkweak/souin v1.7.0 => ../..
199+
github.com/darkweak/souin v1.7.1 => ../..
200200
github.com/darkweak/souin/plugins/souin/storages => ../souin/storages
201201
)

0 commit comments

Comments
 (0)