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