const.go
1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package umeng
const (
Android = iota + 1
IPhone
IPad
)
const (
ProjectDefault = "default"
)
var UMAppAuths UMAppAuth
func init() {
UMAppAuths = map[string]*AppAuth{
ProjectDefault: NewAppAuth(ProjectDefault).
AddAuth(Android, Auth{}).
AddAuth(IPhone, Auth{}),
}
}
type UMAppAuth map[string]*AppAuth
func (a UMAppAuth) DefaultAppAuth() *AppAuth {
return a.GetAppAuth(ProjectDefault)
}
func (a UMAppAuth) GetAppAuth(appName string) *AppAuth {
if auth, ok := a[appName]; ok {
return auth
}
return a.GetAppAuth(ProjectDefault)
}
type AppAuth struct {
AppName string //app名称
AppAuthMap map[int]Auth //android ios ipad
}
//新建
func NewAppAuth(appName string) *AppAuth {
return &AppAuth{
AppName: appName,
AppAuthMap: make(map[int]Auth),
}
}
//添加凭证
func (a *AppAuth) AddAuth(t int, auth Auth) *AppAuth {
if _, ok := a.AppAuthMap[t]; !ok {
a.AppAuthMap[t] = auth
}
return a
}
//凭证
type Auth struct {
AppKey string //应用唯一标识
AppMasterSecret string //服务器秘钥,用于服务器端调用API请求时对发送内容做签名验证
}