From 67b3cf7a74e41fa2d1803a775aec94c1d473bd05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cprongbang=E2=80=9D?= <“prongbang@gmail.com”> Date: Thu, 5 Jan 2023 12:44:41 +0700 Subject: [PATCH] Add field code to response --- middleware.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/middleware.go b/middleware.go index e10aea6..8f155bb 100644 --- a/middleware.go +++ b/middleware.go @@ -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), + }) } }