config.go (view raw)
1package main
2
3import (
4 "github.com/BurntSushi/toml"
5)
6
7type Config struct {
8 FilesDirectory string
9 TemplatesDirectory string
10 Host string
11 SiteTitle string
12 Debug bool
13 SecretKey string
14 DBFile string
15 LogFile string
16 CookieStoreKey string
17 OkExtensions []string
18 MaxFileSize int
19 TLSCertFile string
20 TLSKeyFile string
21}
22
23func getConfig(filename string) (Config, error) {
24 var config Config
25 // Attempt to overwrite defaults from file
26 _, err := toml.DecodeFile(filename, &config)
27 if err != nil {
28 return config, err
29 }
30 return config, nil
31}