update handler options

This commit is contained in:
ginuerzh
2022-01-04 21:56:58 +08:00
parent 566e930010
commit c428b37a36
36 changed files with 468 additions and 524 deletions

View File

@ -11,10 +11,7 @@ type MapAuthenticator struct {
}
// NewMapAuthenticator creates an Authenticator that authenticates client by local infos.
func NewMapAuthenticator(kvs map[string]string) *MapAuthenticator {
if kvs == nil {
kvs = make(map[string]string)
}
func NewMapAuthenticator(kvs map[string]string) Authenticator {
return &MapAuthenticator{
kvs: kvs,
}
@ -22,11 +19,7 @@ func NewMapAuthenticator(kvs map[string]string) *MapAuthenticator {
// Authenticate checks the validity of the provided user-password pair.
func (au *MapAuthenticator) Authenticate(user, password string) bool {
if au == nil {
return true
}
if len(au.kvs) == 0 {
if au == nil || len(au.kvs) == 0 {
return true
}