@@ -7,14 +7,14 @@ import (
7
7
)
8
8
9
9
type Config struct {
10
- RedisUrl string
11
- Bind string
12
- CookieSecret []byte
13
- PasswordSalt []byte
14
- ArchiveDatabase string
15
- ArchiveMaxAge time.Duration
10
+ RedisUrl string
11
+ Bind string
12
+ CookieSecret []byte
13
+ PasswordSalt []byte
14
+ ArchiveDatabase string
15
+ ArchiveMaxAge time.Duration
16
16
MailgunSecretApiKey string
17
- SMTPSecret string
17
+ SMTPSecret string
18
18
}
19
19
20
20
func env (env string ) string {
@@ -32,7 +32,6 @@ func envDefault(env string, fallback string) string {
32
32
return v
33
33
}
34
34
35
-
36
35
func envDuration (envName string ) time.Duration {
37
36
strVal := env (envName )
38
37
duration , err := time .ParseDuration (strVal )
@@ -44,13 +43,13 @@ func envDuration(envName string) time.Duration {
44
43
45
44
func NewConfigFromEnv () Config {
46
45
return Config {
47
- RedisUrl : envDefault ("WEBSTATS_REDIS_URL" , "redis://localhost:6379" ),
48
- Bind : envDefault ("WEBSTATS_BIND" , ":8000" ),
49
- CookieSecret : []byte (env ("WEBSTATS_COOKIE_SECRET" )),
50
- PasswordSalt : []byte (env ("WEBSTATS_PASSWORD_SALT" )),
51
- ArchiveDatabase : env ("WEBSTATS_ARCHIVE_DATABASE" ),
52
- ArchiveMaxAge : envDuration ("WEBSTATS_ARCHIVE_MAX_AGE" ),
53
- MailgunSecretApiKey : envDefault ("WEBSTATS_MAILGUN_SECRET_API_KEY" , "dummy" ),
54
- SMTPSecret : envDefault ("WEBSTATS_SMTP_SECRET" , "dummy" ),
46
+ RedisUrl : envDefault ("WEBSTATS_REDIS_URL" , "redis://localhost:6379" ),
47
+ Bind : envDefault ("WEBSTATS_BIND" , ":8000" ),
48
+ CookieSecret : []byte (env ("WEBSTATS_COOKIE_SECRET" )),
49
+ PasswordSalt : []byte (env ("WEBSTATS_PASSWORD_SALT" )),
50
+ ArchiveDatabase : env ("WEBSTATS_ARCHIVE_DATABASE" ),
51
+ ArchiveMaxAge : envDuration ("WEBSTATS_ARCHIVE_MAX_AGE" ),
52
+ MailgunSecretApiKey : envDefault ("WEBSTATS_MAILGUN_SECRET_API_KEY" , "dummy" ),
53
+ SMTPSecret : envDefault ("WEBSTATS_SMTP_SECRET" , "dummy" ),
55
54
}
56
55
}
0 commit comments