8000 GitHub - tnngo/gin-jwt: JWT Middleware for Gin framework · GitHub
[go: up one dir, main page]

Skip to content
tnngoPublic
forked from appleboy/gin-jwt

About

JWT Middleware for Gin framework

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Repository files navigation

Different

Change the Message parameter of Unauthorized to ERROR type

Example

var A0001 = &Error{Code: "A0001", Err: errors.New("account not found")}

func login(account string) error {
	// do something...

	// if not found.
	return A0001
}


authMiddleware, _ := jwt.New(&jwt.GinJWTMiddleware{
	Authenticator: func(c *gin.Context) (interface{}, error) {
		err := login()
		if err != nil {
			return nil,err
		}

	},
	Unauthorized: func(c *gin.Context, i int, e error) {
		c.JSON(200, e)
	},
})

About

JWT Middleware for Gin framework

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages

0