8000 ErrorHandler JWT · invisiblecoder99/livego@edea272 · GitHub
[go: up one dir, main page]

Skip to content

Commit edea272

Browse files
committed
ErrorHandler JWT
1 parent 8c2757f commit edea272

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

protocol/api/api.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@ func JWTMiddleware(next http.Handler) http.Handler {
8686
return []byte(configure.Config.GetString("jwt.secret")), nil
8787
},
8888
SigningMethod: algorithm,
89+
ErrorHandler: func(w http.ResponseWriter, r *http.Request, err string) {
90+
res := &Response{
91+
w: w,
92+
Status: 403,
93+
Data: err,
94+
}
95+
res.SendJson()
96+
},
8997
})
9098

9199
jwtMiddleware.HandlerWithNext(w, r, next.ServeHTTP)

0 commit comments

Comments
 (0)
0