forked from johnzeng/LeanCloud-go-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LeanClient.go
45 lines (36 loc) · 1.06 KB
/
LeanClient.go
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
package lean
type leanClient struct {
appId, appKey, masterKey string
useSign bool
Installation, User, Role *Collection
File *Collection
}
//create a new lean client.
//You only need one client in a go application
//application will not check your keys if you don't call API that needs it
func NewClient(appId, appKey, masterKey string) *leanClient {
ret := &leanClient{
appId: appId,
appKey: appKey,
masterKey: masterKey,
}
installation := ret.Collection("_Installation")
ret.Installation = &installation
ret.Installation.classSubfix = "/installaions"
user := ret.Collection("_User")
ret.User = &(user)
ret.User.classSubfix = "/users"
role := ret.Collection("_Role")
ret.Role = &(role)
ret.Role.classSubfix = "/roles"
file := ret.Collection("_File")
ret.File = &(file)
ret.File.classSubfix = "/files"
return ret
}
const (
//v1.1 api classes url base
//all url will not end with /,should append it by yourself
UrlBase = "https://api.leancloud.cn/1.1"
ClasssesUrlBase = UrlBase + "/classes"
)