From edea2724034fdc7e8135f2ec426bd90c1f58809c Mon Sep 17 00:00:00 2001 From: Ruben Cid Date: Tue, 14 Apr 2020 15:40:24 +0200 Subject: [PATCH] ErrorHandler JWT --- protocol/api/api.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/protocol/api/api.go b/protocol/api/api.go index 2b242a8..20cb22b 100755 --- a/protocol/api/api.go +++ b/protocol/api/api.go @@ -86,6 +86,14 @@ func JWTMiddleware(next http.Handler) http.Handler { return []byte(configure.Config.GetString("jwt.secret")), nil }, SigningMethod: algorithm, + ErrorHandler: func(w http.ResponseWriter, r *http.Request, err string) { + res := &Response{ + w: w, + Status: 403, + Data: err, + } + res.SendJson() + }, }) jwtMiddleware.HandlerWithNext(w, r, next.ServeHTTP)