diff options
author | Jesús Espino <jespinog@gmail.com> | 2018-06-14 09:00:40 +0200 |
---|---|---|
committer | Carlos Tadeu Panato Junior <ctadeu@gmail.com> | 2018-06-14 09:00:40 +0200 |
commit | 695c5d6bf82f5a5c58aa0a22b4911439f08a80fb (patch) | |
tree | d0ad8946e816cfa4e4b307828178f39cebae1c60 /web/handlers.go | |
parent | a6d815e05a656b1f80a377ae713bc0e31e4a1ef1 (diff) | |
download | chat-695c5d6bf82f5a5c58aa0a22b4911439f08a80fb.tar.gz chat-695c5d6bf82f5a5c58aa0a22b4911439f08a80fb.tar.bz2 chat-695c5d6bf82f5a5c58aa0a22b4911439f08a80fb.zip |
MM-10863: Handle non-API errors with redirect to webapp (#8943)
* MM-10863: Handle non-API errors with redirect to webapp
* Properly shutdown the app in the new test
Diffstat (limited to 'web/handlers.go')
-rw-r--r-- | web/handlers.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/web/handlers.go b/web/handlers.go index aac88aa3a..fe77241e3 100644 --- a/web/handlers.go +++ b/web/handlers.go @@ -157,8 +157,12 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { c.Err.IsOAuth = false } - w.WriteHeader(c.Err.StatusCode) - w.Write([]byte(c.Err.ToJson())) + if IsApiCall(r) || len(r.Header.Get("X-Mobile-App")) > 0 { + w.WriteHeader(c.Err.StatusCode) + w.Write([]byte(c.Err.ToJson())) + } else { + utils.RenderWebAppError(w, r, c.Err, c.App.AsymmetricSigningKey()) + } if c.App.Metrics != nil { c.App.Metrics.IncrementHttpError() |