diff --git a/config/config.go b/config/config.go index 5e34183b..56915ecd 100644 --- a/config/config.go +++ b/config/config.go @@ -11,6 +11,8 @@ import ( type Config struct { Version bool `short:"V" long:"version" description:"Display version."` + Port int `short:"p" long:"port" description:"Port to listen on." default:"8080"` + DB struct { Host string `long:"db-host" env:"DB_HOST" description:"Database host." default:"db"` User string `long:"db-user" env:"DB_USER" description:"Database user." default:"gorm"` diff --git a/main.go b/main.go index 85664a04..60485b0c 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,7 @@ package main import ( + "fmt" "io" "io/ioutil" "net/http" @@ -105,5 +106,5 @@ func main() { http.HandleFunc(util.AddBase("api/attribute/keys"), handleWithDB(api.ListAttributeKeys, database)) // Start server - log.Fatal(http.ListenAndServe(":8080", nil)) + log.Fatal(http.ListenAndServe(fmt.Sprintf(":%v", c.Port), nil)) }