Mercurial > gemma
view config/config.go @ 160:061209505028
feat: Login and logout with session restoration implemented
Login information stored in local storage for restoration after
browser restart. If a non expired session is found, it
is restored before entering the main area.
Username and logout are located in the lower sidebar.
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Wed, 04 Jul 2018 17:21:10 +0200 |
parents | 5ca6f436d0b7 |
children | 3457a60fb12d |
line wrap: on
line source
package config import ( "log" "os" "strconv" ) var Config = NewConfiguration() type Configuration struct { DBHost string DBPort uint DBName string DBSSLMode string JWTSignKey []byte } func NewConfiguration() *Configuration { // TODO: Load from file. return &Configuration{ DBHost: envString("GEMMA_DB_HOST", "localhost"), DBPort: envUint("GEMMA_DB_PORT", 5432), DBName: envString("GEMMA_DB_NAME", "gemma"), DBSSLMode: envString("GEMMA_DB_SSL_MODE", "require"), } } func envString(key, def string) string { if v, ok := os.LookupEnv(key); ok { return v } return def } func envUint(key string, def uint) uint { if v, ok := os.LookupEnv(key); ok { x, err := strconv.ParseUint(v, 10, 64) if err != nil { log.Printf("warn: invalid uint env %s: %v\n", key, err) return def } return uint(x) } return def }