diff --git a/examples/auth/README.md b/examples/auth/README.md index ad24f81c..ae435086 100644 --- a/examples/auth/README.md +++ b/examples/auth/README.md @@ -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") }) } diff --git a/examples/auth/auth.go b/examples/auth/auth.go index e627a5ab..1fc5cae6 100644 --- a/examples/auth/auth.go +++ b/examples/auth/auth.go @@ -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") }) }