all repos — flounder @ 5c25dd5f433771a06e2d3f88173e23bfcdecaf48

A small site builder for the Gemini protocol

config.go (view raw)

 1package main
 2
 3import (
 4	"github.com/BurntSushi/toml"
 5	"path/filepath"
 6)
 7
 8const HiddenFolder = ".hidden"
 9const GemlogFolder = "gemlog"
10
11type Config struct {
12	FilesDirectory     string
13	TemplatesDirectory string
14	Host               string
15	HttpPort           int
16	SiteTitle          string
17	Debug              bool
18	SecretKey          string
19	DBFile             string
20	AnalyticsDBFile    string
21	LogFile            string
22	GeminiCertStore    string
23	CookieStoreKey     string
24	OkExtensions       []string
25	MaxFileBytes       int
26	MaxFilesPerUser    int
27	MaxUserBytes       int64
28	SMTPServer         string
29	SMTPUsername       string
30	SMTPPassword       string
31}
32
33func getConfig(filename string) (Config, error) {
34	var config Config
35	// Attempt to overwrite defaults from file
36	_, err := toml.DecodeFile(filename, &config)
37	if err != nil {
38		return config, err
39	}
40	// Workaround for how some of my path fns are written
41	config.FilesDirectory, _ = filepath.Abs(config.FilesDirectory)
42	return config, nil
43}