Skip to content

Commit

Permalink
Merge pull request #19 from WnP/master
Browse files Browse the repository at this point in the history
[fix] BasicAuth header and return
  • Loading branch information
buaazp committed Dec 15, 2016
2 parents 7778060 + 05b0baa commit ade4e20
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion examples/auth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,11 @@ func BasicAuth(h fasthttp.RequestHandler, requiredUser, requiredPassword string)
if hasAuth && user == requiredUser && password == requiredPassword {
// Delegate request to the given handle
h(ctx)
return
}
// Request Basic Authentication otherwise
ctx.Response.Header.Set("WWW-Authenticate", "Basic realm=Restricted")
ctx.Error(fasthttp.StatusMessage(fasthttp.StatusUnauthorized), fasthttp.StatusUnauthorized)
ctx.Response.Header.Set("WWW-Authenticate", "Basic realm=Restricted")
})
}

Expand Down
3 changes: 2 additions & 1 deletion examples/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@ func BasicAuth(h fasthttp.RequestHandler, requiredUser, requiredPassword string)
if hasAuth && user == requiredUser && password == requiredPassword {
// Delegate request to the given handle
h(ctx)
return
}
// Request Basic Authentication otherwise
ctx.Response.Header.Set("WWW-Authenticate", "Basic realm=Restricted")
ctx.Error(fasthttp.StatusMessage(fasthttp.StatusUnauthorized), fasthttp.StatusUnauthorized)
ctx.Response.Header.Set("WWW-Authenticate", "Basic realm=Restricted")
})
}

Expand Down

0 comments on commit ade4e20

Please sign in to comment.