Skip to content

Commit

Permalink
Add field code to response
Browse files Browse the repository at this point in the history
  • Loading branch information
“prongbang” committed Jan 5, 2023
1 parent 9170ca6 commit 67b3cf7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,16 @@ func middlewareWithConfig(config Config) fiber.Handler {
}
if err != nil && strings.ToLower(err.Error()) == "token is expired" {
return c.Status(http.StatusUnauthorized).
JSON(fiber.Map{"message": err.Error()})
JSON(fiber.Map{
"code": http.StatusUnauthorized,
"message": err.Error(),
})
}
return c.Status(http.StatusForbidden).
JSON(fiber.Map{"message": http.StatusText(http.StatusForbidden)})
JSON(fiber.Map{
"code": http.StatusForbidden,
"message": http.StatusText(http.StatusForbidden),
})
}
}

Expand Down

0 comments on commit 67b3cf7

Please sign in to comment.