pcmt/handlers/config.go
leo 1d421465f5
All checks were successful
continuous-integration/drone/push Build is passing
go: have a dynamic {asset,tmpl}Path
* handle errors more specifically when loading assets/tmpls
2023-04-28 23:16:58 +02:00

40 lines
677 B
Go

package handlers
import (
"io/fs"
"git.dotya.ml/mirre-mt/pcmt/config"
"git.dotya.ml/mirre-mt/pcmt/slogging"
)
var (
conf *config.Config
appver string
log *slogging.Logger
tmplPath string
)
func setConfig(c *config.Config) {
if c != nil {
log.Info("setting handler config")
// c = conf
conf = c
log.Infof("set handler config to %#v", c)
} else {
log.Warn("error passing conf to handlers")
}
}
func setAppVer(v string) {
appver = v
}
func InitHandlers(version, templatesPath string, appconf *config.Config, tmpls fs.FS) {
log = slogging.GetLogger()
tmplPath = templatesPath
setConfig(appconf)
setAppVer(version)
initTemplates(tmpls)
}