diff options
author | a <[email protected]> | 2024-01-13 14:12:43 -0600 |
---|---|---|
committer | GitHub <[email protected]> | 2024-01-13 20:12:43 +0000 |
commit | c839a98ff527932fd14460829142c486f4531a7b (patch) | |
tree | 3a4a9745d2bc54ff557b4439ea0fe2dbc58238e0 /context.go | |
parent | b359ca565c624b8718eac79058bff0591b250d0e (diff) | |
download | caddy-c839a98ff527932fd14460829142c486f4531a7b.tar.gz caddy-c839a98ff527932fd14460829142c486f4531a7b.zip |
filesystem: Globally declared filesystems, `fs` directive (#5833)
Diffstat (limited to 'context.go')
-rw-r--r-- | context.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/context.go b/context.go index 85978d49c..637e4aa91 100644 --- a/context.go +++ b/context.go @@ -23,6 +23,8 @@ import ( "github.com/caddyserver/certmagic" "go.uber.org/zap" + + "github.com/caddyserver/caddy/v2/internal/filesystems" ) // Context is a type which defines the lifetime of modules that @@ -37,6 +39,7 @@ import ( // not actually need to do this). type Context struct { context.Context + moduleInstances map[string][]Module cfg *Config cleanupFuncs []func() @@ -81,6 +84,15 @@ func (ctx *Context) OnCancel(f func()) { ctx.cleanupFuncs = append(ctx.cleanupFuncs, f) } +// Filesystems returns a ref to the FilesystemMap +func (ctx *Context) Filesystems() FileSystems { + // if no config is loaded, we use a default filesystemmap, which includes the osfs + if ctx.cfg == nil { + return &filesystems.FilesystemMap{} + } + return ctx.cfg.filesystems +} + // LoadModule loads the Caddy module(s) from the specified field of the parent struct // pointer and returns the loaded module(s). The struct pointer and its field name as // a string are necessary so that reflection can be used to read the struct tag on the |