jwtdata.go 561 B

12345678910111213141516171819202122232425262728
  1. //@File jwtdata.go
  2. //@Time 2022/04/24
  3. //@Author #Suyghur,
  4. package jwtdata
  5. import "context"
  6. const (
  7. JwtKeyPlayerId = "jwt_player_id"
  8. JwtKeyGameId = "jwt_game_id"
  9. JwtKeyCsId = "jwt_cs_id"
  10. )
  11. func GetPlayerIdFromJwt(ctx context.Context) string {
  12. playerId, _ := ctx.Value(JwtKeyPlayerId).(string)
  13. return playerId
  14. }
  15. func GetGameIdFromJwt(ctx context.Context) string {
  16. gameId, _ := ctx.Value(JwtKeyGameId).(string)
  17. return gameId
  18. }
  19. func GetCsIdFromJwt(ctx context.Context) string {
  20. csId, _ := ctx.Value(JwtKeyCsId).(string)
  21. return csId
  22. }