debug toekn

This commit is contained in:
eson 2023-10-18 15:44:01 +08:00
parent 87d49e2c18
commit 984134aaec
2 changed files with 4 additions and 1 deletions

View File

@ -198,6 +198,9 @@ func GenerateBaseJwtTokenUint64(AccessSecret uint64, accessExpire int64, nowSec
for i := 0; i < myclaimsType.NumField(); i++ {
field := myclaimsType.Field(i)
tag := field.Tag.Get("json")
if tag == "exp" || tag == "iat" {
continue
}
value := myclaimsValue.Field(i).Interface()
// 将字段值赋给 claims 对象的相应键
claims[tag] = value

View File

@ -19,7 +19,7 @@ func TestCase(t *testing.T) {
data, _ := json.Marshal(info)
log.Println(string(data))
a := `{"user_id":0,"guest_id":1,"exp":0, "debug": { "exp": 12321213321}}`
a := `{"user_id":0,"guest_id":1,"exp":0, "debug": { "exp": 123212, "is_cache": 1}}`
err := json.Unmarshal([]byte(a), info)
log.Println(err)
log.Printf("%#v %v", info, info.Debug)