package utils import "github.com/gin-gonic/gin" // SetBridgeLogListByClaims // @Description: 设置上下文中bridge日志 // @author: Roc // @datetime 2024-10-31 10:55:15 // @param c *gin.Context // @param logStr string func SetBridgeLogListByClaims(c *gin.Context, logStr string) { bridgeLogList := GetBridgeLogListByClaims(c) bridgeLogList = append(bridgeLogList, logStr) c.Set("bridge_log", bridgeLogList) return } // GetBridgeLogListByClaims // @Description: 从Claims中获取当前日志 // @author: Roc // @datetime 2024-10-31 10:35:04 // @param c *gin.Context // @return bridgeLogList []string func GetBridgeLogListByClaims(c *gin.Context) (bridgeLogList []string) { //获取jwt数据失败 claims, exists := c.Get("bridge_log") // 如果不存在,那么就是空切片 if !exists { bridgeLogList = []string{} return } bridgeLogList = claims.([]string) return }