Moved interface setting to config

This commit is contained in:
konrad 2017-11-16 13:04:45 +01:00 committed by kolaente
parent c98c593307
commit df0ad4adeb
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
4 changed files with 13 additions and 1 deletions

View File

@ -1,5 +1,7 @@
[General]
JWTSecret = blablaGEHEMIN§)!§
; The interface on which to run the webserver
Interface = :8082
[Database]
User = root

View File

@ -193,6 +193,7 @@ export default {
})
},
getStatusByID: function (id) {
// TODO: is there a better way to do this?
for (const i in this.allStatus) {
if (this.allStatus[i].ID === id) {
return this.allStatus[i].Name

View File

@ -30,5 +30,5 @@ func main() {
// Start the webserver
e := routes.NewEcho()
routes.RegisterRoutes(e)
e.Start(":8082")
e.Start(models.Config.Interface)
}

View File

@ -15,6 +15,7 @@ type ConfigStruct struct {
}
JWTLoginSecret []byte
Interface string
FirstUser User `ini:"User"`
}
@ -30,16 +31,24 @@ func SetConfig() error {
return err
}
// Load the config
cfg, err := ini.Load("config.ini")
if err != nil {
return err
}
// Map the config to our struct
err = cfg.MapTo(Config)
if err != nil {
return err
}
// Set default value for interface to listen on
Config.Interface = cfg.Section("General").Key("Interface").String()
if Config.Interface == "" {
Config.Interface = ":8080"
}
// JWT secret
Config.JWTLoginSecret = []byte(cfg.Section("General").Key("JWTSecret").String())