Footer in eigenes Template verschoben und Logging verbessert
This commit is contained in:
parent
c38286bcc5
commit
4f5dc053a0
14 changed files with 40 additions and 44 deletions
|
@ -11,7 +11,7 @@ import (
|
|||
type Config struct {
|
||||
Server struct {
|
||||
ListenAddress string
|
||||
ListenPort int
|
||||
ListenPort int
|
||||
Protocol string
|
||||
Domain string
|
||||
}
|
||||
|
@ -40,6 +40,9 @@ type Config struct {
|
|||
MysqlPort int
|
||||
MysqlDatabase string
|
||||
}
|
||||
Tutor struct {
|
||||
MailSuffix string
|
||||
}
|
||||
}
|
||||
|
||||
// ReadConfigFile takes a file path as an argument and attempts to
|
||||
|
@ -48,15 +51,18 @@ type Config struct {
|
|||
func ReadConfigFile(filename string, conf *Config) error {
|
||||
configData, err := ioutil.ReadFile(filename)
|
||||
if err != nil {
|
||||
log.Printf("Error reading config file: %s", err.Error())
|
||||
return err
|
||||
}
|
||||
err = json.Unmarshal(configData, conf)
|
||||
if err != nil {
|
||||
log.Printf("Error parsing config file as json: %s", err.Error())
|
||||
return err
|
||||
}
|
||||
return validateConfig(conf)
|
||||
}
|
||||
|
||||
// Checks config for sane values (e.g. correct port range or database type).
|
||||
func validateConfig(conf *Config) error {
|
||||
var err error
|
||||
if !(conf.Server.ListenPort >= 1 && conf.Server.ListenPort <= 65535) {
|
||||
|
@ -64,7 +70,7 @@ func validateConfig(conf *Config) error {
|
|||
log.Println(err.Error())
|
||||
}
|
||||
if !(conf.Server.Protocol == "http" || conf.Server.Protocol == "https") {
|
||||
err = fmt.Errorf("Validating config: Server protocol must be http or https, but is '%s'.", conf.Server.Protocol)
|
||||
err = fmt.Errorf("Validating config: Server protocol must be 'http' or 'https', but is '%s'.", conf.Server.Protocol)
|
||||
log.Println(err.Error())
|
||||
}
|
||||
if !(conf.Date.MinuteGranularity >= 1 && conf.Date.MinuteGranularity <= 60) {
|
||||
|
@ -76,7 +82,7 @@ func validateConfig(conf *Config) error {
|
|||
log.Println(err.Error())
|
||||
}
|
||||
if !(conf.Mailer.Type == "Stdout" || conf.Mailer.Type == "Smtp") {
|
||||
err = fmt.Errorf("Validating config: Mailer type must be 'stdout' or 'smtp', but is '%s'.", conf.Mailer.Type)
|
||||
err = fmt.Errorf("Validating config: Mailer type must be 'Stdout' or 'Smtp', but is '%s'.", conf.Mailer.Type)
|
||||
log.Println(err.Error())
|
||||
}
|
||||
if !(conf.SQL.Type == "SQLite" || conf.SQL.Type == "Mysql") {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue