go(settings): add const defaults
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
eb555cfcad
commit
094a478cf9
@ -40,7 +40,12 @@ type Settings struct {
|
||||
dbIsSetUp bool
|
||||
}
|
||||
|
||||
const appName = "pcmt"
|
||||
const (
|
||||
appName = "pcmt"
|
||||
defaultPort = 3000
|
||||
defaultSessionMaxAge = 86400 // seconds.
|
||||
defaultHTTPDomain = "localhost"
|
||||
)
|
||||
|
||||
// cleantgt is a list of ENV vars pertaining to pcmt.
|
||||
var cleantgt = []string{
|
||||
@ -72,8 +77,8 @@ func (s *Settings) Consolidate(conf *config.Config, host *string, port *int, dev
|
||||
log.Debug("parsing config values")
|
||||
|
||||
if p := conf.Port; p > 0 && p < 65536 {
|
||||
log.Warnf("port '%d', outside of bounds, setting a default of %d/tcp", p, 3000)
|
||||
s.SetPort(3000)
|
||||
log.Warnf("port '%d', outside of bounds, setting a default of %d/tcp", p, defaultPort)
|
||||
s.SetPort(defaultPort)
|
||||
}
|
||||
|
||||
s.SetHost(conf.Host)
|
||||
@ -338,7 +343,7 @@ func (s *Settings) SetSessionCookieEncrSecret(sessionCookieEncrSecret string) {
|
||||
// SetSessionMaxAge sets sessionMaxAge.
|
||||
func (s *Settings) SetSessionMaxAge(sessionMaxAge int) {
|
||||
if sessionMaxAge < 1 {
|
||||
s.sessionMaxAge = 86400
|
||||
s.sessionMaxAge = defaultSessionMaxAge
|
||||
} else {
|
||||
s.sessionMaxAge = sessionMaxAge
|
||||
}
|
||||
@ -348,7 +353,7 @@ func (s *Settings) SetSessionMaxAge(sessionMaxAge int) {
|
||||
func (s *Settings) SetHTTPDomain(domain string) {
|
||||
switch domain {
|
||||
case "":
|
||||
s.httpDomain = "localhost"
|
||||
s.httpDomain = defaultHTTPDomain
|
||||
default:
|
||||
s.httpDomain = domain
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user