summaryrefslogtreecommitdiffstats
path: root/model/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'model/config.go')
-rw-r--r--model/config.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/model/config.go b/model/config.go
index 85b71cb2a..b239c83ca 100644
--- a/model/config.go
+++ b/model/config.go
@@ -6,6 +6,7 @@ package model
import (
"encoding/json"
"io"
+ "net/url"
)
const (
@@ -50,6 +51,7 @@ const (
)
type ServiceSettings struct {
+ SiteURL *string
ListenAddress string
MaximumLoginAttempts int
SegmentDeveloperKey string
@@ -363,6 +365,11 @@ func (o *Config) SetDefaults() {
o.EmailSettings.PasswordResetSalt = NewRandomString(32)
}
+ if o.ServiceSettings.SiteURL == nil {
+ o.ServiceSettings.SiteURL = new(string)
+ *o.ServiceSettings.SiteURL = ""
+ }
+
if o.ServiceSettings.EnableDeveloper == nil {
o.ServiceSettings.EnableDeveloper = new(bool)
*o.ServiceSettings.EnableDeveloper = false
@@ -832,6 +839,16 @@ func (o *Config) IsValid() *AppError {
return NewLocAppError("Config.IsValid", "model.config.is_valid.login_attempts.app_error", nil, "")
}
+ if len(*o.ServiceSettings.SiteURL) != 0 {
+ if _, err := url.ParseRequestURI(*o.ServiceSettings.SiteURL); err != nil {
+ return NewLocAppError("Config.IsValid", "model.config.is_valid.site_url.app_error", nil, "")
+ }
+ }
+
+ if len(o.ServiceSettings.ListenAddress) == 0 {
+ return NewLocAppError("Config.IsValid", "model.config.is_valid.listen_address.app_error", nil, "")
+ }
+
if len(o.ServiceSettings.ListenAddress) == 0 {
return NewLocAppError("Config.IsValid", "model.config.is_valid.listen_address.app_error", nil, "")
}