mirror of
https://github.com/volatiletech/authboss.git
synced 2024-11-28 08:58:38 +02:00
f537664fd9
- Export ModuleAttrMeta so the modules can access it. - Add a couple new events for later use. - Fix a few compile errors. - Prefix err constants with Err.
41 lines
849 B
Go
41 lines
849 B
Go
package authboss
|
|
|
|
var modules = make(map[string]Modularizer)
|
|
|
|
var ModuleAttrMeta = make(AttributeMeta)
|
|
|
|
// Modularizer should be implemented by all the authboss modules.
|
|
type Modularizer interface {
|
|
Initialize(*Config) error
|
|
Routes() RouteTable
|
|
Storage() StorageOptions
|
|
}
|
|
|
|
// RegisterModule with the core providing all the necessary information to
|
|
// integrate into authboss.
|
|
func RegisterModule(name string, m Modularizer) {
|
|
modules[name] = m
|
|
|
|
for k, v := range m.Storage() {
|
|
ModuleAttrMeta[k] = v
|
|
}
|
|
}
|
|
|
|
// LoadedModules returns a list of modules that are currently loaded.
|
|
func LoadedModules() []string {
|
|
mods := make([]string, len(modules))
|
|
i := 0
|
|
for k, _ := range modules {
|
|
mods[i] = k
|
|
i++
|
|
}
|
|
|
|
return mods
|
|
}
|
|
|
|
// IsLoaded checks if a specific module is loaded.
|
|
func IsLoaded(mod string) bool {
|
|
_, ok := modules[mod]
|
|
return ok
|
|
}
|