summaryrefslogtreecommitdiffhomepage
path: root/context.go
diff options
context:
space:
mode:
authorMatt Holt <[email protected]>2023-07-11 13:10:58 -0600
committerGitHub <[email protected]>2023-07-11 19:10:58 +0000
commit0e2c7e1d35b287fc0e56d6db2951f791e09b5a37 (patch)
tree3669f5d01fa351bda933d3796c50a72da9942a01 /context.go
parent7ceef91295343237f5b81ed00e3ba7e8e594d603 (diff)
downloadcaddy-0e2c7e1d35b287fc0e56d6db2951f791e09b5a37.tar.gz
caddy-0e2c7e1d35b287fc0e56d6db2951f791e09b5a37.zip
caddytls: Reuse certificate cache through reloads (#5623)
* caddytls: Don't purge cert cache on config reload * Update CertMagic This actually avoids reloading managed certs from storage when already in the cache, d'oh. * Fix bug; re-implement HasCertificateForSubject * Update go.mod: CertMagic tag
Diffstat (limited to 'context.go')
-rw-r--r--context.go26
1 files changed, 14 insertions, 12 deletions
diff --git a/context.go b/context.go
index 615192c15..004dee600 100644
--- a/context.go
+++ b/context.go
@@ -410,6 +410,11 @@ func (ctx Context) loadModuleInline(moduleNameKey, moduleScope string, raw json.
// called during the Provision/Validate phase to reference a
// module's own host app (since the parent app module is still
// in the process of being provisioned, it is not yet ready).
+//
+// We return any type instead of the App type because it is NOT
+// intended for the caller of this method to be the one to start
+// or stop App modules. The caller is expected to assert to the
+// concrete type.
func (ctx Context) App(name string) (any, error) {
if app, ok := ctx.cfg.apps[name]; ok {
return app, nil
@@ -428,18 +433,15 @@ func (ctx Context) App(name string) (any, error) {
// AppIfConfigured returns an app by its name if it has been
// configured. Can be called instead of App() to avoid
-// instantiating an empty app when that's not desirable.
-func (ctx Context) AppIfConfigured(name string) (any, error) {
- app, ok := ctx.cfg.apps[name]
- if !ok || app == nil {
- return nil, nil
- }
-
- appModule, err := ctx.App(name)
- if err != nil {
- return nil, err
- }
- return appModule, nil
+// instantiating an empty app when that's not desirable. If
+// the app has not been loaded, nil is returned.
+//
+// We return any type instead of the App type because it is not
+// intended for the caller of this method to be the one to start
+// or stop App modules. The caller is expected to assert to the
+// concrete type.
+func (ctx Context) AppIfConfigured(name string) any {
+ return ctx.cfg.apps[name]
}
// Storage returns the configured Caddy storage implementation.