-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathconfig.go
57 lines (51 loc) · 1.32 KB
/
config.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
46
47
48
49
50
51
52
53
54
55
56
57
package goeureka
import (
"strings"
)
//File : config.go
//Author: Simon
//Describe: the config for eureka client
//Date : 2020/12/7
// define eureka config
var configStr = `{
"instance": {
"instanceId" : "${ipAddress}:${appName}:${port}",
"hostName":"${ipAddress}",
"app":"${appName}",
"ipAddr":"${ipAddress}",
"vipAddress":"${appName}",
"overriddenstatus": "UNKNOWN",
"status":"UP",
"port": {
"$":${port},
"@enabled": true
},
"securePort": {
"$":${securePort},
"@enabled": false
},
"homePageUrl" : "http://${ipAddress}:${port}/",
"statusPageUrl": "http://${ipAddress}:${port}/info",
"healthCheckUrl": "http://${ipAddress}:${port}/health",
"dataCenterInfo" : {
"@class":"com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo",
"name": "MyOwn"
},
"metadata": {
"management.port" : "${port}"
}
}
}`
// newConfig load cfg from configStr
func newConfig(appName,localip, port, securePort string) string{
if localip == ""{
localip = getLocalIP()
}
// load config
cfg := string(configStr)
cfg = strings.Replace(cfg, "${ipAddress}", localip, -1)
cfg = strings.Replace(cfg, "${port}", port, -1)
cfg = strings.Replace(cfg, "${securePort}", securePort, -1)
cfg = strings.Replace(cfg, "${appName}", appName, -1)
return cfg
}