From 05b0baa3ed2ff413b985b3664bc0b535f62074b8 Mon Sep 17 00:00:00 2001 From: Steeve Chailloux Date: Thu, 15 Dec 2016 13:07:09 +0100 Subject: [PATCH] [fix] BasicAuth header and return --- examples/auth/README.md | 3 ++- examples/auth/auth.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) 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") }) }