remove hardcode instead of http status value (#1411)

This commit is contained in:
田欧
2018-06-26 17:21:32 +08:00
committed by Bo-Yi Wu
parent 1f59bad84b
commit 6c6d97ba2e
6 changed files with 15 additions and 13 deletions

View File

@ -7,6 +7,7 @@ package gin
import (
"crypto/subtle"
"encoding/base64"
"net/http"
"strconv"
)
@ -51,7 +52,7 @@ func BasicAuthForRealm(accounts Accounts, realm string) HandlerFunc {
if !found {
// Credentials doesn't match, we return 401 and abort handlers chain.
c.Header("WWW-Authenticate", realm)
c.AbortWithStatus(401)
c.AbortWithStatus(http.StatusUnauthorized)
return
}