Skip to content

Commit ade4e20

Browse files
authored
Merge pull request #19 from WnP/master
[fix] BasicAuth header and return
2 parents 7778060 + 05b0baa commit ade4e20

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Diff for: examples/auth/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,11 @@ func BasicAuth(h fasthttp.RequestHandler, requiredUser, requiredPassword string)
5858
if hasAuth && user == requiredUser && password == requiredPassword {
5959
// Delegate request to the given handle
6060
h(ctx)
61+
return
6162
}
6263
// Request Basic Authentication otherwise
63-
ctx.Response.Header.Set("WWW-Authenticate", "Basic realm=Restricted")
6464
ctx.Error(fasthttp.StatusMessage(fasthttp.StatusUnauthorized), fasthttp.StatusUnauthorized)
65+
ctx.Response.Header.Set("WWW-Authenticate", "Basic realm=Restricted")
6566
})
6667
}
6768

Diff for: examples/auth/auth.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,11 @@ func BasicAuth(h fasthttp.RequestHandler, requiredUser, requiredPassword string)
4949
if hasAuth && user == requiredUser && password == requiredPassword {
5050
// Delegate request to the given handle
5151
h(ctx)
52+
return
5253
}
5354
// Request Basic Authentication otherwise
54-
ctx.Response.Header.Set("WWW-Authenticate", "Basic realm=Restricted")
5555
ctx.Error(fasthttp.StatusMessage(fasthttp.StatusUnauthorized), fasthttp.StatusUnauthorized)
56+
ctx.Response.Header.Set("WWW-Authenticate", "Basic realm=Restricted")
5657
})
5758
}
5859

0 commit comments

Comments
 (0)