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-08-27 02:18:41 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/ioutil"
|
|
|
|
"log"
|
|
|
|
|
|
|
|
"gopkg.in/yaml.v2"
|
|
|
|
)
|
|
|
|
|
2016-09-02 21:32:56 +02:00
|
|
|
// Config of warehost webserver
|
2016-08-27 02:18:41 +02:00
|
|
|
type Config struct {
|
|
|
|
Address string `yaml:"address"`
|
|
|
|
Port string `yaml:"port"`
|
|
|
|
Webroot string `yaml:"webroot"`
|
|
|
|
Database string `yaml:"database"`
|
|
|
|
Log struct {
|
|
|
|
Path string `yaml:"path"`
|
|
|
|
} `yaml:"log"`
|
|
|
|
DatabaseDebug bool `yaml:"databasedebug"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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 {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
return config
|
|
|
|
}
|