diff options
| author | Matthew Holt <mholt@users.noreply.github.com> | 2019-05-16 11:46:17 -0600 | 
|---|---|---|
| committer | Matthew Holt <mholt@users.noreply.github.com> | 2019-05-16 11:46:17 -0600 | 
| commit | ff5b4639d597203f8aec43e5eae8fe3774976d32 (patch) | |
| tree | fa7f9d24494f61232c87efd6b68ee7f8909ffb00 /modules.go | |
| parent | f9d93ead4ef6e099ba7e00318dce6509b0f1eda4 (diff) | |
Some minor updates, and get rid of OnLoad/OnUnload
Diffstat (limited to 'modules.go')
| -rw-r--r-- | modules.go | 24 | 
1 files changed, 3 insertions, 21 deletions
@@ -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()  | 
