rename pairMap to authMap

This commit is contained in:
john 2020-06-14 00:38:21 +08:00
parent 0f29b0145c
commit 072c71589f

View File

@ -43,10 +43,10 @@ func BasicAuthForRealm(accounts Accounts, realm string) HandlerFunc {
realm = "Authorization Required" realm = "Authorization Required"
} }
realm = "Basic realm=" + strconv.Quote(realm) realm = "Basic realm=" + strconv.Quote(realm)
pairMap := processAccounts(accounts) authMap := processAccounts(accounts)
return func(c *Context) { return func(c *Context) {
// Search user in the slice of allowed credentials // Search user in the slice of allowed credentials
user, found := pairMap.searchCredential(c.requestHeader("Authorization")) user, found := authMap.searchCredential(c.requestHeader("Authorization"))
if !found { if !found {
// Credentials doesn't match, we return 401 and abort handlers chain. // Credentials doesn't match, we return 401 and abort handlers chain.
c.Header("WWW-Authenticate", realm) c.Header("WWW-Authenticate", realm)