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 HttpsEnabled bool
12 HttpPort string
13 SiteTitle string
14 Debug bool
15 SecretKey string
16 DBFile string
17 LogFile string
18 CookieStoreKey string
19 OkExtensions []string
20 MaxFileSize int
21 TLSCertFile string
22 TLSKeyFile string
23}
24
25func getConfig(filename string) (Config, error) {
26 var config Config
27 // Attempt to overwrite defaults from file
28 _, err := toml.DecodeFile(filename, &config)
29 if err != nil {
30 return config, err
31 }
32 return config, nil
33}