1 Star 0 Fork 0

fkil555/gin-extend

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
app_param_helper.go 781 Bytes
一键复制 编辑 原始数据 按行查看 历史
fkil555 提交于 2024-05-08 15:27 . add helper
package app_param
import (
"context"
)
var defaultAppParam = &AppParam{}
// 内部业务请求之间透传的参数
type AppParam struct {
From string // 来源服务
Version string // 版本号
Platform string // 平台: web android ios
}
func GetAppParam(ctx context.Context) (appParam *AppParam) {
var ok bool
appParam, ok = ctx.Value("appParam").(*AppParam)
if !ok {
appParam = defaultAppParam
}
return
}
// 获取来源
func GetFrom(ctx context.Context) (from string) {
from = GetAppParam(ctx).From
return
}
// 获取版本号
func GetVersion(ctx context.Context) (version string) {
version = GetAppParam(ctx).Version
return
}
// 获取平台
func GetPlatform(ctx context.Context) (platform string) {
platform = GetAppParam(ctx).Platform
return
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/fkil555/gin-extend.git
git@gitee.com:fkil555/gin-extend.git
fkil555
gin-extend
gin-extend
v0.1.2

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385