Skip to content

Commit

Permalink
[fix] BasicAuth header and return
Browse files Browse the repository at this point in the history
  • Loading branch information
chaahk committed Dec 15, 2016
1 parent 7778060 commit 05b0baa
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
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
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 05b0baa

Please sign in to comment.