summaryrefslogtreecommitdiffhomepage
path: root/modules.go
diff options
context:
space:
mode:
authorMatthew Holt <[email protected]>2019-05-16 11:46:17 -0600
committerMatthew Holt <[email protected]>2019-05-16 11:46:17 -0600
commitff5b4639d597203f8aec43e5eae8fe3774976d32 (patch)
treefa7f9d24494f61232c87efd6b68ee7f8909ffb00 /modules.go
parentf9d93ead4ef6e099ba7e00318dce6509b0f1eda4 (diff)
downloadcaddy-ff5b4639d597203f8aec43e5eae8fe3774976d32.tar.gz
caddy-ff5b4639d597203f8aec43e5eae8fe3774976d32.zip
Some minor updates, and get rid of OnLoad/OnUnload
Diffstat (limited to 'modules.go')
-rw-r--r--modules.go24
1 files changed, 3 insertions, 21 deletions
diff --git a/modules.go b/modules.go
index 6afa6fb9f..b2c9b96ff 100644
--- a/modules.go
+++ b/modules.go
@@ -22,27 +22,6 @@ type Module struct {
// It must return a pointer; if not, it
// is converted into one.
New func() (interface{}, error)
-
- // OnLoad is invoked after all module
- // instances ave been loaded. It receives
- // pointers to each instance of this
- // module, and any state from a previous
- // running configuration, which may be
- // nil.
- //
- // If this module is to carry "global"
- // state between all instances through
- // reloads, you might find it helpful
- // to return it.
- // TODO: Is this really better/safer than a global variable?
- OnLoad func(instances []interface{}, priorState interface{}) (newState interface{}, err error)
-
- // OnUnload is called after all module
- // instances have been stopped, possibly
- // in favor of a new configuration. It
- // receives the state given by OnLoad (if
- // any).
- OnUnload func(state interface{}) error
}
func (m Module) String() string { return m.Name }
@@ -53,6 +32,9 @@ func RegisterModule(mod Module) error {
if mod.Name == "caddy" {
return fmt.Errorf("modules cannot be named 'caddy'")
}
+ if strings.HasPrefix(mod.Name, "caddy.") {
+ return fmt.Errorf("modules cannot be namespaced in 'caddy'")
+ }
modulesMu.Lock()
defer modulesMu.Unlock()