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