MCPcopy
hub / github.com/caddyserver/caddy / App

Method App

context.go:505–522  ·  view source on GitHub ↗

App returns the configured app named name. If that app has not yet been loaded and provisioned, it will be immediately loaded and provisioned. If no app with that name is configured, a new empty one will be instantiated instead. (The app module must still be registered.) This must not be called duri

(name string)

Source from the content-addressed store, hash-verified

503// or stop App modules. The caller is expected to assert to the
504// concrete type.
505func (ctx Context) App(name string) (any, error) {
506 // if the app failed to load before, return the cached error
507 if err, ok := ctx.cfg.failedApps[name]; ok {
508 return nil, fmt.Errorf("loading %s app module: %v", name, err)
509 }
510 if app, ok := ctx.cfg.apps[name]; ok {
511 return app, nil
512 }
513 appRaw := ctx.cfg.AppsRaw[name]
514 modVal, err := ctx.LoadModuleByID(name, appRaw)
515 if err != nil {
516 return nil, fmt.Errorf("loading %s app module: %v", name, err)
517 }
518 if appRaw != nil {
519 ctx.cfg.AppsRaw[name] = nil // allow GC to deallocate
520 }
521 return modVal, nil
522}
523
524// AppIfConfigured is like App, but it returns an error if the
525// app has not been configured. This is useful when the app is

Callers 11

AppIfConfiguredMethod · 0.95
provisionContextFunction · 0.80
ProvisionMethod · 0.80
makeClientMethod · 0.80
ProvisionMethod · 0.80
ProvisionMethod · 0.80
cmdRespondFunction · 0.80
ProvisionMethod · 0.80
MakeTLSClientConfigMethod · 0.80
ProvisionMethod · 0.80

Calls 1

LoadModuleByIDMethod · 0.95

Tested by

no test coverage detected