Skip to content

Commit 8a819c2

Browse files
authored
feat(dependencies): bump to Souin v1.6.39 (#56)
1 parent 1384484 commit 8a819c2

File tree

6 files changed

+204
-10
lines changed

6 files changed

+204
-10
lines changed

Diff for: Caddyfile

+52
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,15 @@ route /custom-key/without-* {
287287
respond "Hello to the authenticated user."
288288
}
289289

290+
route /must-revalidate {
291+
cache {
292+
ttl 5s
293+
stale 5s
294+
}
295+
header Cache-Control "must-revalidate"
296+
reverse_proxy 127.0.0.1:81
297+
}
298+
290299
route /cache-authorization {
291300
cache {
292301
cache_keys {
@@ -299,6 +308,49 @@ route /cache-authorization {
299308
respond "Hello to the authenticated user."
300309
}
301310

311+
route /bypass {
312+
cache {
313+
mode bypass
314+
}
315+
316+
header Cache-Control "no-store"
317+
respond "Hello bypass"
318+
}
319+
320+
route /bypass_request {
321+
cache {
322+
mode bypass_request
323+
}
324+
325+
respond "Hello bypass_request"
326+
}
327+
328+
route /bypass_response {
329+
cache {
330+
mode bypass_response
331+
}
332+
333+
header Cache-Control "no-cache, no-store"
334+
respond "Hello bypass_response"
335+
}
336+
337+
route /strict_request {
338+
cache {
339+
mode strict
340+
}
341+
342+
respond "Hello strict"
343+
}
344+
345+
route /strict_response {
346+
cache {
347+
mode strict
348+
}
349+
350+
header Cache-Control "no-cache, no-store"
351+
respond "Hello strict"
352+
}
353+
302354
cache @souin-api {
303355
}
304356

Diff for: README.md

+2
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ Here are all the available options for the global options
7979
headers Content-Type Authorization
8080
}
8181
log_level debug
82+
mode bypass
8283
nuts {
8384
path /path/to/the/storage
8485
}
@@ -384,6 +385,7 @@ What does these directives mean?
384385
| `key.disable_query` | Disable the query string part in the key | `true`<br/><br/>`(default: false)` |
385386
| `key.headers` | Add headers to the key matching the regexp | `Authorization Content-Type X-Additional-Header` |
386387
| `key.hide` | Prevent the key from being exposed in the `Cache-Status` HTTP response header | `true`<br/><br/>`(default: false)` |
388+
| `mode` | Bypass the RFC respect | One of `bypass` `bypass_request` `bypass_response` `strict` (default `strict`) |
387389
| `nuts` | Configure the Nuts cache storage | |
388390
| `nuts.path` | Set the Nuts file path storage | `/anywhere/nuts/storage` |
389391
| `nuts.configuration` | Configure Nuts directly in the Caddyfile or your JSON caddy configuration | [See the Nuts configuration for the options](https://github.com/nutsdb/nutsdb#default-options) |

Diff for: configuration.go

+42-3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ type DefaultCache struct {
2828
Headers []string `json:"headers"`
2929
// Configure the global key generation.
3030
Key configurationtypes.Key `json:"key"`
31+
// Mode defines if strict or bypass.
32+
Mode string `json:"mode"`
3133
// Olric provider configuration.
3234
Olric configurationtypes.CacheProvider `json:"olric"`
3335
// Redis provider configuration.
@@ -86,6 +88,11 @@ func (d *DefaultCache) GetEtcd() configurationtypes.CacheProvider {
8688
return d.Etcd
8789
}
8890

91+
// GetMode returns mdoe configuration
92+
func (d *DefaultCache) GetMode() string {
93+
return d.Mode
94+
}
95+
8996
// GetNuts returns nuts configuration
9097
func (d *DefaultCache) GetNuts() configurationtypes.CacheProvider {
9198
return d.Nuts
@@ -274,6 +281,8 @@ func parseConfiguration(cfg *Configuration, h *caddyfile.Dispenser, isBlocking b
274281
switch directive {
275282
case "basepath":
276283
apiConfiguration.Debug.BasePath = h.RemainingArgs()[0]
284+
default:
285+
return h.Errf("unsupported debug directive: %s", directive)
277286
}
278287
}
279288
case "prometheus":
@@ -284,6 +293,8 @@ func parseConfiguration(cfg *Configuration, h *caddyfile.Dispenser, isBlocking b
284293
switch directive {
285294
case "basepath":
286295
apiConfiguration.Prometheus.BasePath = h.RemainingArgs()[0]
296+
default:
297+
return h.Errf("unsupported prometheus directive: %s", directive)
287298
}
288299
}
289300
case "souin":
@@ -294,8 +305,12 @@ func parseConfiguration(cfg *Configuration, h *caddyfile.Dispenser, isBlocking b
294305
switch directive {
295306
case "basepath":
296307
apiConfiguration.Souin.BasePath = h.RemainingArgs()[0]
308+
default:
309+
return h.Errf("unsupported souin directive: %s", directive)
297310
}
298311
}
312+
default:
313+
return h.Errf("unsupported api directive: %s", directive)
299314
}
300315
}
301316
cfg.API = apiConfiguration
@@ -310,6 +325,8 @@ func parseConfiguration(cfg *Configuration, h *caddyfile.Dispenser, isBlocking b
310325
case "configuration":
311326
provider.Configuration = parseCaddyfileRecursively(h)
312327
provider.Configuration = parseBadgerConfiguration(provider.Configuration.(map[string]interface{}))
328+
default:
329+
return h.Errf("unsupported badger directive: %s", directive)
313330
}
314331
}
315332
cfg.DefaultCache.Badger = provider
@@ -337,6 +354,8 @@ func parseConfiguration(cfg *Configuration, h *caddyfile.Dispenser, isBlocking b
337354
ck.Hide = true
338355
case "headers":
339356
ck.Headers = h.RemainingArgs()
357+
default:
358+
return h.Errf("unsupported cache_keys (%s) directive: %s", rg, directive)
340359
}
341360
}
342361

@@ -367,6 +386,8 @@ func parseConfiguration(cfg *Configuration, h *caddyfile.Dispenser, isBlocking b
367386
cdn.Provider = h.RemainingArgs()[0]
368387
case "strategy":
369388
cdn.Strategy = h.RemainingArgs()[0]
389+
default:
390+
return h.Errf("unsupported cdn directive: %s", directive)
370391
}
371392
}
372393
cfg.DefaultCache.CDN = cdn
@@ -381,6 +402,8 @@ func parseConfiguration(cfg *Configuration, h *caddyfile.Dispenser, isBlocking b
381402
switch directive {
382403
case "configuration":
383404
provider.Configuration = parseCaddyfileRecursively(h)
405+
default:
406+
return h.Errf("unsupported etcd directive: %s", directive)
384407
}
385408
}
386409
cfg.DefaultCache.Etcd = provider
@@ -403,12 +426,20 @@ func parseConfiguration(cfg *Configuration, h *caddyfile.Dispenser, isBlocking b
403426
config_key.Hide = true
404427
case "headers":
405428
config_key.Headers = h.RemainingArgs()
429+
default:
430+
return h.Errf("unsupported key directive: %s", directive)
406431
}
407432
}
408433
cfg.DefaultCache.Key = config_key
409434
case "log_level":
410435
args := h.RemainingArgs()
411436
cfg.LogLevel = args[0]
437+
case "mode":
438+
args := h.RemainingArgs()
439+
if len(args) > 1 {
440+
return h.Errf("mode must contains only one arg: %s given", args)
441+
}
442+
cfg.DefaultCache.Mode = args[0]
412443
case "nuts":
413444
provider := configurationtypes.CacheProvider{}
414445
for nesting := h.Nesting(); h.NextBlock(nesting); {
@@ -422,6 +453,8 @@ func parseConfiguration(cfg *Configuration, h *caddyfile.Dispenser, isBlocking b
422453
provider.Path = urlArgs[0]
423454
case "configuration":
424455
provider.Configuration = parseCaddyfileRecursively(h)
456+
default:
457+
return h.Errf("unsupported nuts directive: %s", directive)
425458
}
426459
}
427460
cfg.DefaultCache.Nuts = provider
@@ -439,6 +472,8 @@ func parseConfiguration(cfg *Configuration, h *caddyfile.Dispenser, isBlocking b
439472
provider.Path = urlArgs[0]
440473
case "configuration":
441474
provider.Configuration = parseCaddyfileRecursively(h)
475+
default:
476+
return h.Errf("unsupported olric directive: %s", directive)
442477
}
443478
}
444479
cfg.DefaultCache.Olric = provider
@@ -457,6 +492,8 @@ func parseConfiguration(cfg *Configuration, h *caddyfile.Dispenser, isBlocking b
457492
case "configuration":
458493
provider.Configuration = parseCaddyfileRecursively(h)
459494
provider.Configuration = parseRedisConfiguration(provider.Configuration.(map[string]interface{}))
495+
default:
496+
return h.Errf("unsupported redis directive: %s", directive)
460497
}
461498
}
462499
cfg.DefaultCache.Redis = provider
@@ -466,6 +503,8 @@ func parseConfiguration(cfg *Configuration, h *caddyfile.Dispenser, isBlocking b
466503
switch directive {
467504
case "exclude":
468505
cfg.DefaultCache.Regex.Exclude = h.RemainingArgs()[0]
506+
default:
507+
return h.Errf("unsupported regex directive: %s", directive)
469508
}
470509
}
471510
case "stale":
@@ -493,6 +532,8 @@ func parseConfiguration(cfg *Configuration, h *caddyfile.Dispenser, isBlocking b
493532
d.Duration = ttl
494533
}
495534
timeout.Cache = d
535+
default:
536+
return h.Errf("unsupported timeout directive: %s", directive)
496537
}
497538
}
498539
cfg.DefaultCache.Timeout = timeout
@@ -503,9 +544,7 @@ func parseConfiguration(cfg *Configuration, h *caddyfile.Dispenser, isBlocking b
503544
cfg.DefaultCache.TTL.Duration = ttl
504545
}
505546
default:
506-
if isBlocking {
507-
return h.Errf("unsupported root directive: %s", rootOption)
508-
}
547+
return h.Errf("unsupported root directive: %s", rootOption)
509548
}
510549
}
511550
}

Diff for: go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.19
55
require (
66
github.com/buraksezer/olric v0.5.4
77
github.com/caddyserver/caddy/v2 v2.6.4
8-
github.com/darkweak/souin v1.6.36
8+
github.com/darkweak/souin v1.6.39
99
go.uber.org/zap v1.24.0
1010
)
1111

@@ -102,7 +102,7 @@ require (
102102
github.com/mschoch/smat v0.2.0 // indirect
103103
github.com/onsi/ginkgo/v2 v2.9.0 // indirect
104104
github.com/pkg/errors v0.9.1 // indirect
105-
github.com/pquerna/cachecontrol v0.1.0 // indirect
105+
github.com/pquerna/cachecontrol v0.1.1-0.20230415224848-baaf0ee61529 // indirect
106106
github.com/prometheus/client_golang v1.14.0 // indirect
107107
github.com/prometheus/client_model v0.3.0 // indirect
108108
github.com/prometheus/common v0.41.0 // indirect

Diff for: go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -656,8 +656,8 @@ github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7Do
656656
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
657657
github.com/darkweak/go-esi v0.0.5 h1:b9LHI8Tz46R+i6p8avKPHAIBRQUCZDebNmKm5w/Zrns=
658658
github.com/darkweak/go-esi v0.0.5/go.mod h1:koCJqwum1u6mslyZuq/Phm6hfG1K3ZK5Y7jrUBTH654=
659-
github.com/darkweak/souin v1.6.36 h1:T+7xZFjnDgbjOPF/1jEFj3cBcTMK6hzdG0X3iQiGkGg=
660-
github.com/darkweak/souin v1.6.36/go.mod h1:/C9ISWex+bkdmHgAT2wZpq9VQddcMLb0i8/ykrapN40=
659+
github.com/darkweak/souin v1.6.39 h1:uVO18+pvy5N8dJH+CCfuBD3gx7AXWaBv+RjC9ee1pCk=
660+
github.com/darkweak/souin v1.6.39/go.mod h1:7B7VqPbFrF7AWJDRP6FCbE+zGiRUUqHAmWOs3Q2n4hk=
661661
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
662662
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
663663
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -1115,8 +1115,8 @@ github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qR
11151115
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
11161116
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
11171117
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
1118-
github.com/pquerna/cachecontrol v0.1.0 h1:yJMy84ti9h/+OEWa752kBTKv4XC30OtVVHYv/8cTqKc=
1119-
github.com/pquerna/cachecontrol v0.1.0/go.mod h1:NrUG3Z7Rdu85UNR3vm7SOsl1nFIeSiQnrHV5K9mBcUI=
1118+
github.com/pquerna/cachecontrol v0.1.1-0.20230415224848-baaf0ee61529 h1:wcNVCAIsWcLpEJ5FhXHKC7dBi6SIZQukrOTY5eHes0M=
1119+
github.com/pquerna/cachecontrol v0.1.1-0.20230415224848-baaf0ee61529/go.mod h1:NrUG3Z7Rdu85UNR3vm7SOsl1nFIeSiQnrHV5K9mBcUI=
11201120
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
11211121
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
11221122
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=

0 commit comments

Comments
 (0)