forked from mirror/gin
refactor: using requestHeader internal func (#1083)
* refactor: using requestHeader internal func. * update Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
fa391a4864
commit
211c48f040
2
auth.go
2
auth.go
|
@ -47,7 +47,7 @@ func BasicAuthForRealm(accounts Accounts, realm string) HandlerFunc {
|
|||
pairs := processAccounts(accounts)
|
||||
return func(c *Context) {
|
||||
// Search user in the slice of allowed credentials
|
||||
user, found := pairs.searchCredential(c.Request.Header.Get("Authorization"))
|
||||
user, found := pairs.searchCredential(c.requestHeader("Authorization"))
|
||||
if !found {
|
||||
// Credentials doesn't match, we return 401 and abort handlers chain.
|
||||
c.Header("WWW-Authenticate", realm)
|
||||
|
|
|
@ -509,7 +509,7 @@ func (c *Context) ClientIP() string {
|
|||
}
|
||||
|
||||
if c.engine.AppEngine {
|
||||
if addr := c.Request.Header.Get("X-Appengine-Remote-Addr"); addr != "" {
|
||||
if addr := c.requestHeader("X-Appengine-Remote-Addr"); addr != "" {
|
||||
return addr
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue