diff --git a/configuration/config.go b/configuration/config.go index 2286c4bfaecc66ab4be8451cde9f91bb8a224fc8..688d37a490ff2a3df2d52fe3749459e904622826 100644 --- a/configuration/config.go +++ b/configuration/config.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "os" + "unicode" fp "path/filepath" configParser "github.com/caarlos0/env/v9" @@ -18,6 +19,8 @@ var version string = "n/a" type Config struct { Version string + FontColor string `env:"FONT_COLOR" envDefault:""` + LogLevel string `env:"LOG_LEVE" envDefault:"error"` Environment string `env:"ENV_NAME" envDefault:"development"` @@ -65,7 +68,6 @@ func New() ( *Config, error ){ ) } - if len( cfg.DatabaseHost ) >= 1 && len( cfg.DatabasePassword ) >= 2 { if ! fp.IsLocal( cfg.DatabasePassword ) && ! fp.IsAbs( cfg.DatabasePassword ) { return nil, errors.New( @@ -85,6 +87,22 @@ func New() ( *Config, error ){ } } + if len( cfg.FontColor ) >= 1 { + if len( cfg.FontColor ) >= 21 { + return nil, errors.New( + fmt.Sprintln( "Font color too long" ), + ) + } + + for _, r := range cfg.FontColor { + if ! unicode.IsLetter( r ) { + return nil, errors.New( + fmt.Sprintln( "Invalid character in font color" ), + ) + } + } + } + return &cfg, nil } diff --git a/routing/routes.go b/routing/routes.go index b787c8d6a11e107bd7ee428cafa3526f1df9d9fd..183609fa4261d99c08fe7d17c923422b2286df73 100644 --- a/routing/routes.go +++ b/routing/routes.go @@ -48,7 +48,7 @@ func SetRoutes( router *f.App, config *configuration.Config, store state.Store, data := indexHtmlData{ Version: config.Version, - Color: "", + Color: config.FontColor, } buffer := &bytes.Buffer{}