add auther api

This commit is contained in:
ginuerzh
2022-02-12 14:12:09 +08:00
parent 345338d410
commit fdd67a6086
10 changed files with 293 additions and 13 deletions

View File

@ -18,8 +18,11 @@ type autherRegistry struct {
m sync.Map
}
func (r *autherRegistry) Register(name string, auth auth.Authenticator) error {
if _, loaded := r.m.LoadOrStore(name, auth); loaded {
func (r *autherRegistry) Register(name string, auther auth.Authenticator) error {
if name == "" || auther == nil {
return nil
}
if _, loaded := r.m.LoadOrStore(name, auther); loaded {
return ErrDup
}