diff options
Diffstat (limited to 'api4/context.go')
-rw-r--r-- | api4/context.go | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/api4/context.go b/api4/context.go index 8f663431d..36a48eb9d 100644 --- a/api4/context.go +++ b/api4/context.go @@ -19,14 +19,14 @@ import ( ) type Context struct { - Session model.Session - Params *ApiParams - Err *model.AppError - T goi18n.TranslateFunc - RequestId string - IpAddress string - Path string - siteURL string + Session model.Session + Params *ApiParams + Err *model.AppError + T goi18n.TranslateFunc + RequestId string + IpAddress string + Path string + siteURLHeader string } func ApiHandler(h func(*Context, http.ResponseWriter, *http.Request)) http.Handler { @@ -125,12 +125,7 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { isTokenFromQueryString = true } - if utils.GetSiteURL() == "" { - protocol := app.GetProtocol(r) - c.SetSiteURL(protocol + "://" + r.Host) - } else { - c.SetSiteURL(utils.GetSiteURL()) - } + c.SetSiteURLHeader(app.GetProtocol(r) + "://" + r.Host) w.Header().Set(model.HEADER_REQUEST_ID, c.RequestId) w.Header().Set(model.HEADER_VERSION_ID, fmt.Sprintf("%v.%v.%v.%v", model.CurrentVersion, model.BuildNumber, utils.CfgHash, utils.IsLicensed)) @@ -320,12 +315,12 @@ func (c *Context) SetPermissionError(permission *model.Permission) { c.Err.StatusCode = http.StatusForbidden } -func (c *Context) SetSiteURL(url string) { - c.siteURL = strings.TrimRight(url, "/") +func (c *Context) SetSiteURLHeader(url string) { + c.siteURLHeader = strings.TrimRight(url, "/") } -func (c *Context) GetSiteURL() string { - return c.siteURL +func (c *Context) GetSiteURLHeader() string { + return c.siteURLHeader } func (c *Context) RequireUserId() *Context { |