Configuration

* Added flags to customize the host and port
* Start up just one server rather than a server for HTTP and HTTPS.  HTTPS server will only start if a cert and key are found
This commit is contained in:
Stash Dev
2019-04-11 10:55:58 -07:00
parent 3a00a29fb4
commit 29a40c5bdd
12 changed files with 114 additions and 60 deletions

View File

@@ -12,6 +12,9 @@ const Downloads = "downloads"
const Database = "database"
const Host = "host"
const Port = "port"
func Set(key string, value interface{}) {
viper.Set(key, value)
}
@@ -40,6 +43,14 @@ func GetDatabasePath() string {
return viper.GetString(Database)
}
func GetHost() string {
return viper.GetString(Host)
}
func GetPort() int {
return viper.GetInt(Port)
}
func IsValid() bool {
setPaths := viper.IsSet(Stash) && viper.IsSet(Cache) && viper.IsSet(Generated) && viper.IsSet(Metadata)
// TODO: check valid paths