Moved interface setting to config
This commit is contained in:
parent
c98c593307
commit
df0ad4adeb
|
@ -1,5 +1,7 @@
|
|||
[General]
|
||||
JWTSecret = blablaGEHEMIN§)!§
|
||||
; The interface on which to run the webserver
|
||||
Interface = :8082
|
||||
|
||||
[Database]
|
||||
User = root
|
||||
|
|
|
@ -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
|
||||
|
|
2
main.go
2
main.go
|
@ -30,5 +30,5 @@ func main() {
|
|||
// Start the webserver
|
||||
e := routes.NewEcho()
|
||||
routes.RegisterRoutes(e)
|
||||
e.Start(":8082")
|
||||
e.Start(models.Config.Interface)
|
||||
}
|
||||
|
|
|
@ -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())
|
||||
|
||||
|
|
Loading…
Reference in New Issue