about summary refs log tree commit diff stats
path: root/svc/conf.go
diff options
context:
space:
mode:
authorBen Morrison <ben@gbmor.dev>2020-04-12 14:45:43 -0400
committerBen Morrison <ben@gbmor.dev>2020-04-12 15:46:23 -0400
commit0daa948c9c6b507f1f087d57941ef35c26c97ae0 (patch)
treeef671bf2b358d568472faecb778c9499c50df024 /svc/conf.go
parentf2bf68aedafb7b1df3c8d853ed7c9f7d35029de3 (diff)
downloadgetwtxt-0daa948c9c6b507f1f087d57941ef35c26c97ae0.tar.gz
Allowing static files to be served directly from
a directory specified in the config.

Added a handler to svc.go:Start() to serve /static/
Added default value in conf.go for "StaticFilesDirectory" in the
config file.
Read the value of StaticFilesDirectory in config to the config
global in conf.go
Diffstat (limited to 'svc/conf.go')
-rw-r--r--svc/conf.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/svc/conf.go b/svc/conf.go
index ae52219..8968ed4 100644
--- a/svc/conf.go
+++ b/svc/conf.go
@@ -41,7 +41,8 @@ type Configuration struct {
 	ReqLog        string        `yaml:"RequestLog"`
 	DBType        string        `yaml:"DatabaseType"`
 	DBPath        string        `yaml:"DatabasePath"`
-	AssetsDir     string        `yaml:"-"`
+	AssetsDir     string        `yaml:"AssetsDirectory"`
+	StaticDir     string        `yaml:"StaticFilesDirectory"`
 	StdoutLogging bool          `yaml:"StdoutLogging"`
 	CacheInterval time.Duration `yaml:"StatusFetchInterval"`
 	DBInterval    time.Duration `yaml:"DatabasePushInterval"`
@@ -120,6 +121,7 @@ func setConfigDefaults() {
 	viper.SetDefault("RequestLog", "logs/request.log")
 	viper.SetDefault("DatabasePath", "getwtxt.db")
 	viper.SetDefault("AssetsDirectory", "assets")
+	viper.SetDefault("StaticFilesDirectory", "static")
 	viper.SetDefault("DatabaseType", "leveldb")
 	viper.SetDefault("StdoutLogging", false)
 	viper.SetDefault("ReCacheInterval", "1h")
@@ -167,6 +169,7 @@ func bindConfig() {
 	confObj.DBType = strings.ToLower(viper.GetString("DatabaseType"))
 	confObj.DBPath = viper.GetString("DatabasePath")
 	confObj.AssetsDir = viper.GetString("AssetsDirectory")
+	confObj.StaticDir = viper.GetString("StaticFilesDirectory")
 	confObj.StdoutLogging = viper.GetBool("StdoutLogging")
 	confObj.CacheInterval = viper.GetDuration("StatusFetchInterval")
 	confObj.DBInterval = viper.GetDuration("DatabasePushInterval")
@@ -207,4 +210,5 @@ func announceConfig() {
 	log.Printf("Using %v database: %v\n", confObj.DBType, confObj.DBPath)
 	log.Printf("Database push interval: %v\n", confObj.DBInterval)
 	log.Printf("User status fetch interval: %v\n", confObj.CacheInterval)
+	log.Printf("Static files directory: %v", confObj.StaticDir)
 }