diff --git a/config.ini b/config.ini index feae0d1..fe1f941 100644 --- a/config.ini +++ b/config.ini @@ -1,5 +1,7 @@ [General] JWTSecret = blablaGEHEMIN§)!§ +; The interface on which to run the webserver +Interface = :8082 [Database] User = root diff --git a/frontend/src/components/Books.vue b/frontend/src/components/Books.vue index b0a561c..200b32f 100644 --- a/frontend/src/components/Books.vue +++ b/frontend/src/components/Books.vue @@ -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 diff --git a/main.go b/main.go index e23e06e..4becc47 100644 --- a/main.go +++ b/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) } diff --git a/models/config.go b/models/config.go index 40f2daa..8680aef 100644 --- a/models/config.go +++ b/models/config.go @@ -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())