mirror of
https://github.com/caddyserver/caddy.git
synced 2025-05-25 12:20:34 +08:00
Separate currentCtxMu to protect currentCtx, and a new rawCfgMu to protect rawCfg and synchronize loads.
This commit is contained in:
@ -441,6 +441,12 @@ func (ctx Context) App(name string) (any, error) {
|
||||
// or stop App modules. The caller is expected to assert to the
|
||||
// concrete type.
|
||||
func (ctx Context) AppIfConfigured(name string) any {
|
||||
if ctx.cfg == nil {
|
||||
// this can happen if the currently-active context
|
||||
// is being accessed, but no config has successfully
|
||||
// been loaded yet
|
||||
return nil
|
||||
}
|
||||
return ctx.cfg.apps[name]
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user