-
Notifications
You must be signed in to change notification settings - Fork 4
/
setup.go
45 lines (38 loc) · 1.04 KB
/
setup.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 flowablesdk
import "strings"
type Config struct {
Url string // 请求地址
Username string // 用户名
Password string // 密码
ProcessPrefix string // 流程API前缀
FormPrefix string // 表单API前缀
RequestDebug bool // 是否打印请求日志
ResponseDebug bool // 是否打印返回日志
}
var Configs Config
func Setup(c Config) {
if len(c.Url) == 0 {
c.Url = "http://127.0.0.1:8080"
} else {
c.Url = strings.Trim(c.Url, "/")
}
if len(c.ProcessPrefix) == 0 {
c.ProcessPrefix = "/service"
} else {
c.ProcessPrefix = strings.Trim(c.ProcessPrefix, "/")
c.ProcessPrefix = "/" + c.ProcessPrefix
}
if len(c.FormPrefix) == 0 {
c.FormPrefix = "/form-api"
} else {
c.FormPrefix = strings.Trim(c.FormPrefix, "/")
c.FormPrefix = "/" + c.FormPrefix
}
Configs.Url = c.Url
Configs.Username = c.Username
Configs.Password = c.Password
Configs.ProcessPrefix = c.ProcessPrefix
Configs.FormPrefix = c.FormPrefix
Configs.RequestDebug = c.RequestDebug
Configs.ResponseDebug = c.ResponseDebug
}