diff options
author | Harrison Healey <harrisonmhealey@gmail.com> | 2016-08-02 16:37:09 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-02 16:37:09 -0400 |
commit | c4a3118e9f885e92bb9b7d882898e9a51fc3be69 (patch) | |
tree | 7564e7aa04e7c656781b34375d6964d029755c38 /api/context.go | |
parent | e67bbcb0ae483cc86ae3a80ace36f1e6e663b589 (diff) | |
download | chat-c4a3118e9f885e92bb9b7d882898e9a51fc3be69.tar.gz chat-c4a3118e9f885e92bb9b7d882898e9a51fc3be69.tar.bz2 chat-c4a3118e9f885e92bb9b7d882898e9a51fc3be69.zip |
PLT-3408 Add SiteURL to config.json (#3692)
* PLT-3408 Changed serverside code to get the service's URL from config.json
* PLT-3408 Changed most clientside code to use the SiteURL config setting instead of window.location
* PLT-3408 Changed default SiteURL to be autodetected
Diffstat (limited to 'api/context.go')
-rw-r--r-- | api/context.go | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/api/context.go b/api/context.go index b26778711..6976feb8f 100644 --- a/api/context.go +++ b/api/context.go @@ -39,7 +39,6 @@ type Context struct { Err *model.AppError teamURLValid bool teamURL string - siteURL string T goi18n.TranslateFunc Locale string TeamId string @@ -139,8 +138,11 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { isTokenFromQueryString = true } - protocol := GetProtocol(r) - c.SetSiteURL(protocol + "://" + r.Host) + // if the site url in the config isn't specified, infer if from this request and write it back to the config + if *utils.Cfg.ServiceSettings.SiteURL == "" { + *utils.Cfg.ServiceSettings.SiteURL = GetProtocol(r) + "://" + r.Host + utils.RegenerateClientConfig() + } w.Header().Set(model.HEADER_REQUEST_ID, c.RequestId) w.Header().Set(model.HEADER_VERSION_ID, fmt.Sprintf("%v.%v", model.CurrentVersion, utils.CfgLastModified)) @@ -180,7 +182,7 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { c.Path = r.URL.Path } else { splitURL := strings.Split(r.URL.Path, "/") - c.setTeamURL(protocol+"://"+r.Host+"/"+splitURL[1], true) + c.setTeamURL(c.GetSiteURL()+"/"+splitURL[1], true) c.Path = "/" + strings.Join(splitURL[2:], "/") } @@ -431,10 +433,6 @@ func (c *Context) SetTeamURLFromSession() { } } -func (c *Context) SetSiteURL(url string) { - c.siteURL = url -} - func (c *Context) GetTeamURLFromTeam(team *model.Team) string { return c.GetSiteURL() + "/" + team.Name } @@ -450,7 +448,7 @@ func (c *Context) GetTeamURL() string { } func (c *Context) GetSiteURL() string { - return c.siteURL + return *utils.Cfg.ServiceSettings.SiteURL } func IsApiCall(r *http.Request) bool { |