-
Notifications
You must be signed in to change notification settings - Fork 28
/
main.go
78 lines (60 loc) · 2.41 KB
/
main.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package main
import "log"
var (
// TibiadataDefaultVoc - default vocation when not specified in request
TibiadataDefaultVoc string = "all"
// Tibiadata app flags for running
TibiadataAPIversion int = 3
TibiadataDebug bool
// Tibiadata app settings
TibiadataHost string // set through env TIBIADATA_HOST
// Tibiadata app details set to release/build on GitHub
TibiadataBuildRelease = "unknown" // will be set by GitHub Actions (to release number)
TibiadataBuildBuilder = "manual" // will be set by GitHub Actions
TibiadataBuildCommit = "-" // will be set by GitHub Actions (to git commit)
TibiadataBuildEdition = "open-source" //
)
func main() {
// logging start of TibiaData
log.Printf("[info] TibiaData API starting..")
// running the TibiaDataInitializer function
TibiaDataInitializer()
// logging build information
log.Printf("[info] TibiaData API release: %s", TibiadataBuildRelease)
log.Printf("[info] TibiaData API build: %s", TibiadataBuildBuilder)
log.Printf("[info] TibiaData API commit: %s", TibiadataBuildCommit)
log.Printf("[info] TibiaData API edition: %s", TibiadataBuildEdition)
// setting tibiadata-application to log much less if DEBUG_MODE is false (default is false)
if !getEnvAsBool("DEBUG_MODE", false) {
log.Printf("[info] TibiaData API debug-mode: disabled")
} else {
// setting debug to true for more logging
TibiadataDebug = true
log.Printf("[info] TibiaData API debug-mode: enabled")
// logging user-agent string
log.Printf("[debug] TIbiaData API User-Agent: %s", TibiadataUserAgent)
}
// starting webserver.go stuff
runWebServer()
}
// TibiaDataInitializer func - init things at beginning
func TibiaDataInitializer() {
// setting TibiadataBuildEdition
if isEnvExist("TIBIADATA_EDITION") {
TibiadataBuildEdition = getEnv("TIBIADATA_EDITION", "open-source")
}
// adding information of host
TibiadataHost = getEnv("TIBIADATA_HOST", "")
if TibiadataHost != "" {
TibiadataHost = "+https://" + TibiadataHost
}
// generating TibiadataUserAgent with TibiadataUserAgentGenerator function
TibiadataUserAgent = TibiadataUserAgentGenerator(TibiadataAPIversion)
// setting TibiadataProxyDomain
if isEnvExist("TIBIADATA_PROXY") {
TibiadataProxyDomain = "https://" + getEnv("TIBIADATA_PROXY", "www.tibia.com") + "/"
}
log.Printf("[info] TibiaData API proxy: %s", TibiadataProxyDomain)
// initializing houses mappings
TibiaDataHousesMappingInitiator()
}