This repository has been archived on 2020-09-27. You can view files and clone it, but cannot push or open issues or pull requests.
2016-11-24 23:58:03 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/ioutil"
|
|
|
|
|
|
|
|
"gopkg.in/yaml.v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Config of warehost webserver
|
|
|
|
type Config struct {
|
2017-05-05 23:03:42 +02:00
|
|
|
Database string `yaml:"database"`
|
|
|
|
WelcomeMessage string `yaml:"welcome_message"`
|
|
|
|
Log struct {
|
2016-11-27 10:46:50 +01:00
|
|
|
Path string `yaml:"path"`
|
|
|
|
} `yaml:"log"`
|
|
|
|
DatabaseDebug bool `yaml:"databasedebug"`
|
2016-12-19 12:24:18 +01:00
|
|
|
Own string `yaml:"own"`
|
2016-11-27 10:46:50 +01:00
|
|
|
Host string `yaml:"host"`
|
|
|
|
Web string `yaml:"web"`
|
|
|
|
Port int `yaml:"port"`
|
2017-05-05 23:03:42 +02:00
|
|
|
SSL struct {
|
|
|
|
Public string `yaml:"public"`
|
|
|
|
Private string `yaml:"private"`
|
|
|
|
} `yaml:"ssl"`
|
2016-11-24 23:58:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ReadConfigFile reads a config models by path to a yml file
|
|
|
|
func ReadConfigFile(path string) *Config {
|
|
|
|
config := &Config{}
|
|
|
|
file, _ := ioutil.ReadFile(path)
|
|
|
|
err := yaml.Unmarshal(file, &config)
|
|
|
|
if err != nil {
|
2016-11-27 10:46:50 +01:00
|
|
|
panic(err)
|
2016-11-24 23:58:03 +01:00
|
|
|
}
|
|
|
|
return config
|
|
|
|
}
|