Make some config with default value
This commit is contained in:
parent
dec43cdddb
commit
02202b94d5
|
|
@ -5,4 +5,6 @@ xmpp_hostname=xmppsteam.kingpenguin.tk
|
||||||
xmpp_secret=xmpp4steam_password
|
xmpp_secret=xmpp4steam_password
|
||||||
xmpp_debug=true
|
xmpp_debug=true
|
||||||
|
|
||||||
|
# HTTP informations
|
||||||
http_port=9090
|
http_port=9090
|
||||||
|
http_timeoute_sec=60
|
||||||
|
|
|
||||||
18
main.go
18
main.go
|
|
@ -17,6 +17,9 @@ import (
|
||||||
const (
|
const (
|
||||||
Version = "v0.1.0"
|
Version = "v0.1.0"
|
||||||
configurationFilePath = "httpAuth.cfg"
|
configurationFilePath = "httpAuth.cfg"
|
||||||
|
|
||||||
|
default_xmpp_server_address = "127.0.0.1"
|
||||||
|
default_xmpp_server_port = "5347"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
@ -32,17 +35,26 @@ func init() {
|
||||||
// HTTP config
|
// HTTP config
|
||||||
httpTimeout, err := strconv.Atoi(mapConfig["http_timeoute_sec"])
|
httpTimeout, err := strconv.Atoi(mapConfig["http_timeoute_sec"])
|
||||||
if err == nil {
|
if err == nil {
|
||||||
log.Println("Define HTTP timeout to %d second", httpTimeout)
|
log.Println("Define HTTP timeout to "+strconv.Itoa(httpTimeout)+" second")
|
||||||
http.TimeoutSec = httpTimeout
|
http.TimeoutSec = httpTimeout
|
||||||
}
|
}
|
||||||
httpPort, err := strconv.Atoi(mapConfig["http_port"])
|
httpPort, err := strconv.Atoi(mapConfig["http_port"])
|
||||||
if err == nil {
|
if err == nil {
|
||||||
log.Println("Define HTTP port to %d", httpPort)
|
log.Println("Define HTTP port to "+strconv.Itoa(httpPort))
|
||||||
http.HttpPortBind = httpPort
|
http.HttpPortBind = httpPort
|
||||||
}
|
}
|
||||||
|
|
||||||
// XMPP config
|
// XMPP config
|
||||||
xmpp.Addr = mapConfig["xmpp_server_address"] + ":" + mapConfig["xmpp_server_port"]
|
xmpp_server_address := mapConfig["xmpp_server_address"]
|
||||||
|
if xmpp_server_address == "" {
|
||||||
|
xmpp_server_address = default_xmpp_server_address
|
||||||
|
}
|
||||||
|
xmpp_server_port := mapConfig["xmpp_server_port"]
|
||||||
|
if xmpp_server_port == "" {
|
||||||
|
xmpp_server_port = default_xmpp_server_port
|
||||||
|
}
|
||||||
|
|
||||||
|
xmpp.Addr = xmpp_server_address + ":" + xmpp_server_port
|
||||||
xmpp.JidStr = mapConfig["xmpp_hostname"]
|
xmpp.JidStr = mapConfig["xmpp_hostname"]
|
||||||
xmpp.Secret = mapConfig["xmpp_secret"]
|
xmpp.Secret = mapConfig["xmpp_secret"]
|
||||||
xmpp.Debug = mapConfig["xmpp_debug"] == "true"
|
xmpp.Debug = mapConfig["xmpp_debug"] == "true"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue