Header.go 778 Bytes
package getWay

import (
	"git.168cad.top/zhengqiuyun/rym-util/exception"
	"github.com/gin-gonic/gin"
)

const headerKeyToken = "token"

const headerKeyPlatformCode = "platform"

const headerKeyClientSource = "clientSource"

func getHeader(c *gin.Context, key string) string {
	v := c.GetHeader(key)
	return v
}

func GetToken(c *gin.Context) string {
	return getHeader(c, headerKeyToken)
}

func SetToken(v string, c *gin.Context) {
	c.Header(headerKeyToken, v)
}

func GetPlatformCode(c *gin.Context) string {
	platformCode := getHeader(c, headerKeyPlatformCode)
	if platformCode == "" {
		exception.ThrowsErrS("平台错误")
	}
	return platformCode
}

func GetClientSource(c *gin.Context) string {
	platformCode := getHeader(c, headerKeyClientSource)
	return platformCode
}