diff --git a/config.go b/config.go new file mode 100644 index 0000000..db9739d --- /dev/null +++ b/config.go @@ -0,0 +1,27 @@ +package main + +import ( + "log" + "os" + "path/filepath" + + "github.com/BurntSushi/toml" +) + +type Config struct { + Host string `toml:"host"` + TMDBApiKey string `toml:"tmdbApiKey"` + DBName string `toml:"dbName"` + UploadFolder string `toml:"uploadFolder"` +} + +func NewConfig(path string) Config { + var c Config + f := filepath.Join(path, "config.toml") + _, err := toml.DecodeFile(f, &c) + if err != nil { + log.Println("Could not read the config file", err) + os.Exit(1) + } + return c +}