all repos — flounder @ 8e2aeacaa3a8f9d86f032d657c9c390d55e1be72

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	HttpsEnabled          bool
16	HttpPort              int
17	SiteTitle             string
18	Debug                 bool
19	SecretKey             string
20	DBFile                string
21	LogFile               string
22	GeminiCertStore       string
23	CookieStoreKey        string
24	OkExtensions          []string
25	MaxFileBytes          int
26	MaxUserBytes          int64
27	TLSCertFile           string
28	TLSKeyFile            string
29	SMTPServer            string
30	SMTPUsername          string
31	SMTPPassword          string
32	PrometheusMetrics     bool
33	PrometheusMetricsPort string
34}
35
36func getConfig(filename string) (Config, error) {
37	var config Config
38	// Attempt to overwrite defaults from file
39	_, err := toml.DecodeFile(filename, &config)
40	if err != nil {
41		return config, err
42	}
43	// Workaround for how some of my path fns are written
44	config.FilesDirectory, _ = filepath.Abs(config.FilesDirectory)
45	return config, nil
46}