feat: allow port to be set in config
This commit is contained in:
@@ -7,12 +7,15 @@ import (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Port int `json:"port"`
|
||||
DatabasePath string `json:"databasePath"`
|
||||
TemplateDirectoryPath string `json:"templateDirectoryPath"`
|
||||
HostKeyDirectoryPath string `json:"hostKeyDirectoryPath"`
|
||||
HostName string `json:"hostName"`
|
||||
}
|
||||
|
||||
const defaultPort = 8080
|
||||
|
||||
func ReadConfigFrom(reader io.Reader) (Config, error) {
|
||||
var config Config
|
||||
err := json.NewDecoder(reader).Decode(&config)
|
||||
@@ -35,5 +38,9 @@ func ReadConfigFrom(reader io.Reader) (Config, error) {
|
||||
return Config{}, err
|
||||
}
|
||||
|
||||
if config.Port == 0 {
|
||||
config.Port = defaultPort
|
||||
}
|
||||
|
||||
return config, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user