@@ -28,6 +28,8 @@ type DefaultCache struct {
28
28
Headers []string `json:"headers"`
29
29
// Configure the global key generation.
30
30
Key configurationtypes.Key `json:"key"`
31
+ // Mode defines if strict or bypass.
32
+ Mode string `json:"mode"`
31
33
// Olric provider configuration.
32
34
Olric configurationtypes.CacheProvider `json:"olric"`
33
35
// Redis provider configuration.
@@ -86,6 +88,11 @@ func (d *DefaultCache) GetEtcd() configurationtypes.CacheProvider {
86
88
return d .Etcd
87
89
}
88
90
91
+ // GetMode returns mdoe configuration
92
+ func (d * DefaultCache ) GetMode () string {
93
+ return d .Mode
94
+ }
95
+
89
96
// GetNuts returns nuts configuration
90
97
func (d * DefaultCache ) GetNuts () configurationtypes.CacheProvider {
91
98
return d .Nuts
@@ -274,6 +281,8 @@ func parseConfiguration(cfg *Configuration, h *caddyfile.Dispenser, isBlocking b
274
281
switch directive {
275
282
case "basepath" :
276
283
apiConfiguration .Debug .BasePath = h .RemainingArgs ()[0 ]
284
+ default :
285
+ return h .Errf ("unsupported debug directive: %s" , directive )
277
286
}
278
287
}
279
288
case "prometheus" :
@@ -284,6 +293,8 @@ func parseConfiguration(cfg *Configuration, h *caddyfile.Dispenser, isBlocking b
284
293
switch directive {
285
294
case "basepath" :
286
295
apiConfiguration .Prometheus .BasePath = h .RemainingArgs ()[0 ]
296
+ default :
297
+ return h .Errf ("unsupported prometheus directive: %s" , directive )
287
298
}
288
299
}
289
300
case "souin" :
@@ -294,8 +305,12 @@ func parseConfiguration(cfg *Configuration, h *caddyfile.Dispenser, isBlocking b
294
305
switch directive {
295
306
case "basepath" :
296
307
apiConfiguration .Souin .BasePath = h .RemainingArgs ()[0 ]
308
+ default :
309
+ return h .Errf ("unsupported souin directive: %s" , directive )
297
310
}
298
311
}
312
+ default :
313
+ return h .Errf ("unsupported api directive: %s" , directive )
299
314
}
300
315
}
301
316
cfg .API = apiConfiguration
@@ -310,6 +325,8 @@ func parseConfiguration(cfg *Configuration, h *caddyfile.Dispenser, isBlocking b
310
325
case "configuration" :
311
326
provider .Configuration = parseCaddyfileRecursively (h )
312
327
provider .Configuration = parseBadgerConfiguration (provider .Configuration .(map [string ]interface {}))
328
+ default :
329
+ return h .Errf ("unsupported badger directive: %s" , directive )
313
330
}
314
331
}
315
332
cfg .DefaultCache .Badger = provider
@@ -337,6 +354,8 @@ func parseConfiguration(cfg *Configuration, h *caddyfile.Dispenser, isBlocking b
337
354
ck .Hide = true
338
355
case "headers" :
339
356
ck .Headers = h .RemainingArgs ()
357
+ default :
358
+ return h .Errf ("unsupported cache_keys (%s) directive: %s" , rg , directive )
340
359
}
341
360
}
342
361
@@ -367,6 +386,8 @@ func parseConfiguration(cfg *Configuration, h *caddyfile.Dispenser, isBlocking b
367
386
cdn .Provider = h .RemainingArgs ()[0 ]
368
387
case "strategy" :
369
388
cdn .Strategy = h .RemainingArgs ()[0 ]
389
+ default :
390
+ return h .Errf ("unsupported cdn directive: %s" , directive )
370
391
}
371
392
}
372
393
cfg .DefaultCache .CDN = cdn
@@ -381,6 +402,8 @@ func parseConfiguration(cfg *Configuration, h *caddyfile.Dispenser, isBlocking b
381
402
switch directive {
382
403
case "configuration" :
383
404
provider .Configuration = parseCaddyfileRecursively (h )
405
+ default :
406
+ return h .Errf ("unsupported etcd directive: %s" , directive )
384
407
}
385
408
}
386
409
cfg .DefaultCache .Etcd = provider
@@ -403,12 +426,20 @@ func parseConfiguration(cfg *Configuration, h *caddyfile.Dispenser, isBlocking b
403
426
config_key .Hide = true
404
427
case "headers" :
405
428
config_key .Headers = h .RemainingArgs ()
429
+ default :
430
+ return h .Errf ("unsupported key directive: %s" , directive )
406
431
}
407
432
}
408
433
cfg .DefaultCache .Key = config_key
409
434
case "log_level" :
410
435
args := h .RemainingArgs ()
411
436
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 ]
412
443
case "nuts" :
413
444
provider := configurationtypes.CacheProvider {}
414
445
for nesting := h .Nesting (); h .NextBlock (nesting ); {
@@ -422,6 +453,8 @@ func parseConfiguration(cfg *Configuration, h *caddyfile.Dispenser, isBlocking b
422
453
provider .Path = urlArgs [0 ]
423
454
case "configuration" :
424
455
provider .Configuration = parseCaddyfileRecursively (h )
456
+ default :
457
+ return h .Errf ("unsupported nuts directive: %s" , directive )
425
458
}
426
459
}
427
460
cfg .DefaultCache .Nuts = provider
@@ -439,6 +472,8 @@ func parseConfiguration(cfg *Configuration, h *caddyfile.Dispenser, isBlocking b
439
472
provider .Path = urlArgs [0 ]
440
473
case "configuration" :
441
474
provider .Configuration = parseCaddyfileRecursively (h )
475
+ default :
476
+ return h .Errf ("unsupported olric directive: %s" , directive )
442
477
}
443
478
}
444
479
cfg .DefaultCache .Olric = provider
@@ -457,6 +492,8 @@ func parseConfiguration(cfg *Configuration, h *caddyfile.Dispenser, isBlocking b
457
492
case "configuration" :
458
493
provider .Configuration = parseCaddyfileRecursively (h )
459
494
provider .Configuration = parseRedisConfiguration (provider .Configuration .(map [string ]interface {}))
495
+ default :
496
+ return h .Errf ("unsupported redis directive: %s" , directive )
460
497
}
461
498
}
462
499
cfg .DefaultCache .Redis = provider
@@ -466,6 +503,8 @@ func parseConfiguration(cfg *Configuration, h *caddyfile.Dispenser, isBlocking b
466
503
switch directive {
467
504
case "exclude" :
468
505
cfg .DefaultCache .Regex .Exclude = h .RemainingArgs ()[0 ]
506
+ default :
507
+ return h .Errf ("unsupported regex directive: %s" , directive )
469
508
}
470
509
}
471
510
case "stale" :
@@ -493,6 +532,8 @@ func parseConfiguration(cfg *Configuration, h *caddyfile.Dispenser, isBlocking b
493
532
d .Duration = ttl
494
533
}
495
534
timeout .Cache = d
535
+ default :
536
+ return h .Errf ("unsupported timeout directive: %s" , directive )
496
537
}
497
538
}
498
539
cfg .DefaultCache .Timeout = timeout
@@ -503,9 +544,7 @@ func parseConfiguration(cfg *Configuration, h *caddyfile.Dispenser, isBlocking b
503
544
cfg .DefaultCache .TTL .Duration = ttl
504
545
}
505
546
default :
506
- if isBlocking {
507
- return h .Errf ("unsupported root directive: %s" , rootOption )
508
- }
547
+ return h .Errf ("unsupported root directive: %s" , rootOption )
509
548
}
510
549
}
511
550
}
0 commit comments