Skip to content

Commit 67b3cf7

Browse files
author
“prongbang”
committed
Add field code to response
1 parent 9170ca6 commit 67b3cf7

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

middleware.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,16 @@ func middlewareWithConfig(config Config) fiber.Handler {
5858
}
5959
if err != nil && strings.ToLower(err.Error()) == "token is expired" {
6060
return c.Status(http.StatusUnauthorized).
61-
JSON(fiber.Map{"message": err.Error()})
61+
JSON(fiber.Map{
62+
"code": http.StatusUnauthorized,
63+
"message": err.Error(),
64+
})
6265
}
6366
return c.Status(http.StatusForbidden).
64-
JSON(fiber.Map{"message": http.StatusText(http.StatusForbidden)})
67+
JSON(fiber.Map{
68+
"code": http.StatusForbidden,
69+
"message": http.StatusText(http.StatusForbidden),
70+
})
6571
}
6672
}
6773

0 commit comments

Comments
 (0)