From eda438530371fefaea0737ae2ba906b48fe589f3 Mon Sep 17 00:00:00 2001 From: Kensuke Kubo Date: Tue, 2 Feb 2021 11:19:55 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20map[string]interface{}=E3=82=92Claims?= =?UTF-8?q?=E3=81=A7=E3=82=B7=E3=83=A7=E3=83=BC=E3=83=88=E3=82=AB=E3=83=83?= =?UTF-8?q?=E3=83=88=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jwt.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/jwt.go b/jwt.go index f7fcab8..e36534e 100644 --- a/jwt.go +++ b/jwt.go @@ -14,6 +14,8 @@ import ( "time" ) +type Claims map[string]interface{} + type Option struct { privateKey *rsa.PrivateKey Issuer string @@ -85,7 +87,7 @@ func setOption(option Option) { options = option } -func GetToken(claims map[string]interface{}) ([]byte, error) { +func GetToken(claims Claims) ([]byte, error) { var err error t := jwt.New() @@ -143,9 +145,9 @@ func Verify(c *gin.Context) { return } -func GetClaims(c *gin.Context) map[string]interface{} { +func GetClaims(c *gin.Context) Claims { if claims, ok := c.Get("claims"); ok { - return claims.(map[string]interface{}) + return claims.(Claims) } else { return nil }