1
0
mirror of https://github.com/volatiletech/authboss.git synced 2024-11-24 08:42:17 +02:00
authboss/module.go
Aaron 92b3172a3e Add a lot of module related stuff.
- Leave a failing test to make hate not love.
2015-01-05 00:18:41 -08:00

44 lines
933 B
Go

package authboss
import (
"net/http"
)
var modules = make(map[string]Modularizer)
// RouteTable is a routing table from a path to a handlerfunc.
type RouteTable map[string]http.HandlerFunc
// StorageOptions is a map depicting the things a module must be able to store.
type StorageOptions map[string]DataType
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
}
// 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
}