Moved interface setting to config
This commit is contained in:
parent
c98c593307
commit
df0ad4adeb
|
@ -1,5 +1,7 @@
|
||||||
[General]
|
[General]
|
||||||
JWTSecret = blablaGEHEMIN§)!§
|
JWTSecret = blablaGEHEMIN§)!§
|
||||||
|
; The interface on which to run the webserver
|
||||||
|
Interface = :8082
|
||||||
|
|
||||||
[Database]
|
[Database]
|
||||||
User = root
|
User = root
|
||||||
|
|
|
@ -193,6 +193,7 @@ export default {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
getStatusByID: function (id) {
|
getStatusByID: function (id) {
|
||||||
|
// TODO: is there a better way to do this?
|
||||||
for (const i in this.allStatus) {
|
for (const i in this.allStatus) {
|
||||||
if (this.allStatus[i].ID === id) {
|
if (this.allStatus[i].ID === id) {
|
||||||
return this.allStatus[i].Name
|
return this.allStatus[i].Name
|
||||||
|
|
2
main.go
2
main.go
|
@ -30,5 +30,5 @@ func main() {
|
||||||
// Start the webserver
|
// Start the webserver
|
||||||
e := routes.NewEcho()
|
e := routes.NewEcho()
|
||||||
routes.RegisterRoutes(e)
|
routes.RegisterRoutes(e)
|
||||||
e.Start(":8082")
|
e.Start(models.Config.Interface)
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ type ConfigStruct struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
JWTLoginSecret []byte
|
JWTLoginSecret []byte
|
||||||
|
Interface string
|
||||||
|
|
||||||
FirstUser User `ini:"User"`
|
FirstUser User `ini:"User"`
|
||||||
}
|
}
|
||||||
|
@ -30,16 +31,24 @@ func SetConfig() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Load the config
|
||||||
cfg, err := ini.Load("config.ini")
|
cfg, err := ini.Load("config.ini")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Map the config to our struct
|
||||||
err = cfg.MapTo(Config)
|
err = cfg.MapTo(Config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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
|
// JWT secret
|
||||||
Config.JWTLoginSecret = []byte(cfg.Section("General").Key("JWTSecret").String())
|
Config.JWTLoginSecret = []byte(cfg.Section("General").Key("JWTSecret").String())
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue