From ff5b4639d597203f8aec43e5eae8fe3774976d32 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Thu, 16 May 2019 11:46:17 -0600 Subject: Some minor updates, and get rid of OnLoad/OnUnload --- modules.go | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) (limited to 'modules.go') diff --git a/modules.go b/modules.go index 6afa6fb..b2c9b96 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() -- cgit v1.2.3