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

Method Provision

modules/caddyfs/filesystem.go:60–80  ·  view source on GitHub ↗
(ctx caddy.Context)

Source from the content-addressed store, hash-verified

58func (xs *Filesystems) Stop() error { return nil }
59
60func (xs *Filesystems) Provision(ctx caddy.Context) error {
61 // load the filesystem module
62 for _, f := range xs.Filesystems {
63 if len(f.FileSystemRaw) > 0 {
64 mod, err := ctx.LoadModule(f, "FileSystemRaw")
65 if err != nil {
66 return fmt.Errorf("loading file system module: %v", err)
67 }
68 f.fileSystem = mod.(fs.FS)
69 }
70 // register that module
71 ctx.Logger().Debug("registering fs", zap.String("fs", f.Key))
72 ctx.FileSystems().Register(f.Key, f.fileSystem)
73 // remember to unregister the module when we are done
74 xs.defers = append(xs.defers, func() {
75 ctx.Logger().Debug("unregistering fs", zap.String("fs", f.Key))
76 ctx.FileSystems().Unregister(f.Key)
77 })
78 }
79 return nil
80}
81
82func (f *Filesystems) Cleanup() error {
83 for _, v := range f.defers {

Callers

nothing calls this directly

Calls 6

LoadModuleMethod · 0.80
FileSystemsMethod · 0.80
RegisterMethod · 0.65
UnregisterMethod · 0.65
LoggerMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected