-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathapp.go
More file actions
63 lines (54 loc) · 1.64 KB
/
app.go
File metadata and controls
63 lines (54 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package httpcache
import (
"github.com/caddyserver/caddy/v2"
"github.com/darkweak/souin/configurationtypes"
"github.com/darkweak/souin/pkg/storage/types"
"github.com/darkweak/souin/pkg/surrogate/providers"
"github.com/darkweak/storages/core"
)
// SouinApp contains the whole Souin necessary items
type SouinApp struct {
DefaultCache
// The provider to use.
Storers []types.Storer
// Surrogate storage to support the configuration reload without surrogate-key data loss.
SurrogateStorage providers.SurrogateInterface
// SurrogateKeyDisabled opt-out the Surrogate key system.
SurrogateKeyDisabled bool
// Cache-key tweaking.
CacheKeys configurationtypes.CacheKeys `json:"cache_keys,omitempty"`
// API endpoints enablers.
API configurationtypes.API `json:"api,omitempty"`
// Logger level, fallback on caddy's one when not redefined.
LogLevel string `json:"log_level,omitempty"`
}
func init() {
caddy.RegisterModule(SouinApp{})
}
// Provision implements caddy.Provisioner
func (s SouinApp) Provision(_ caddy.Context) error {
return nil
}
// Start will start the App
func (s SouinApp) Start() error {
core.ResetRegisteredStorages()
_, _ = up.Delete(stored_providers_key)
_, _ = up.LoadOrStore(stored_providers_key, newStorageProvider())
return nil
}
// Stop will stop the App
func (s SouinApp) Stop() error {
return nil
}
// CaddyModule implements caddy.ModuleInfo
func (s SouinApp) CaddyModule() caddy.ModuleInfo {
return caddy.ModuleInfo{
ID: moduleName,
New: func() caddy.Module { return new(SouinApp) },
}
}
var (
_ caddy.App = (*SouinApp)(nil)
_ caddy.Module = (*SouinApp)(nil)
_ caddy.Provisioner = (*SouinApp)(nil)
)