Fix Content-Type not being set on invalidAuthResponse
When `w.WriteHeader(...)` is called, the HTTP headers are written in the HTTP response. Therefore, calling `w.Header().Add(...)` after `w.WriteHeader(...)` will not have any effect. Signed-off-by: Ionut Balutoiu <ibalutoiu@cloudbasesolutions.com>
This commit is contained in:
parent
8089244c9c
commit
4787622450
1 changed files with 1 additions and 1 deletions
|
|
@ -74,8 +74,8 @@ func (amw *jwtMiddleware) claimsToContext(ctx context.Context, claims *JWTClaims
|
|||
}
|
||||
|
||||
func invalidAuthResponse(w http.ResponseWriter) {
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
w.Header().Add("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
if err := json.NewEncoder(w).Encode(
|
||||
apiParams.APIErrorResponse{
|
||||
Error: "Authentication failed",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue