mirror of
https://github.com/APIParkLab/APIPark.git
synced 2026-06-14 20:41:15 +08:00
34 lines
650 B
Go
34 lines
650 B
Go
package auth_driver
|
|
|
|
import "github.com/eolinker/eosc"
|
|
|
|
var (
|
|
defaultManager = NewManager()
|
|
)
|
|
|
|
type Manager struct {
|
|
authFactory eosc.Untyped[string, IFactory]
|
|
}
|
|
|
|
func NewManager() *Manager {
|
|
return &Manager{
|
|
authFactory: eosc.BuildUntyped[string, IFactory](),
|
|
}
|
|
}
|
|
|
|
func (m *Manager) RegisterAuth(name string, auth IFactory) {
|
|
m.authFactory.Set(name, auth)
|
|
}
|
|
|
|
func (m *Manager) GetAuth(name string) (IFactory, bool) {
|
|
return m.authFactory.Get(name)
|
|
}
|
|
|
|
func GetAuthFactory(name string) (IFactory, bool) {
|
|
return defaultManager.GetAuth(name)
|
|
}
|
|
|
|
func RegisterAuthFactory(name string, auth IFactory) {
|
|
defaultManager.RegisterAuth(name, auth)
|
|
}
|