[MM-61077] Fix errcheck issues in server/channels/web/static.go (#29285)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
Этот коммит содержится в:
@@ -190,7 +190,6 @@ issues:
|
|||||||
channels/utils/license_test.go|\
|
channels/utils/license_test.go|\
|
||||||
channels/web/oauth_test.go|\
|
channels/web/oauth_test.go|\
|
||||||
channels/web/saml.go|\
|
channels/web/saml.go|\
|
||||||
channels/web/static.go|\
|
|
||||||
channels/web/web_test.go|\
|
channels/web/web_test.go|\
|
||||||
channels/web/webhook.go|\
|
channels/web/webhook.go|\
|
||||||
cmd/mattermost/commands/cmdtestlib.go|\
|
cmd/mattermost/commands/cmdtestlib.go|\
|
||||||
|
|||||||
@@ -64,7 +64,12 @@ func root(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
w.Header().Set("Cache-Control", "no-store")
|
w.Header().Set("Cache-Control", "no-store")
|
||||||
data := renderUnsupportedBrowser(c.AppContext, r)
|
data := renderUnsupportedBrowser(c.AppContext, r)
|
||||||
|
|
||||||
c.App.Srv().TemplatesContainer().Render(w, "unsupported_browser", data)
|
err := c.App.Srv().TemplatesContainer().Render(w, "unsupported_browser", data)
|
||||||
|
if err != nil {
|
||||||
|
c.Logger.Error("Failed to render template", mlog.Err(err))
|
||||||
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,7 +83,10 @@ func root(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
staticDir, _ := fileutils.FindDir(model.ClientDir)
|
staticDir, _ := fileutils.FindDir(model.ClientDir)
|
||||||
contents, err := os.ReadFile(filepath.Join(staticDir, "root.html"))
|
contents, err := os.ReadFile(filepath.Join(staticDir, "root.html"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusNotFound)
|
c.Logger.Warn("Failed to read content from file",
|
||||||
|
mlog.String("file_path", filepath.Join(staticDir, "root.html")),
|
||||||
|
mlog.Err(err))
|
||||||
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,7 +98,11 @@ func root(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "text/html")
|
w.Header().Set("Content-Type", "text/html")
|
||||||
w.Write(contents)
|
if _, err = w.Write(contents); err != nil {
|
||||||
|
c.Logger.Warn("Failed to write content to HTTP reply", mlog.Err(err))
|
||||||
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func staticFilesHandler(handler http.Handler) http.Handler {
|
func staticFilesHandler(handler http.Handler) http.Handler {
|
||||||
@@ -135,7 +147,11 @@ func robotsHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
http.NotFound(w, r)
|
http.NotFound(w, r)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.Write(robotsTxt)
|
if _, err := w.Write(robotsTxt); err != nil {
|
||||||
|
mlog.Warn("Failed to write robots.txt", mlog.Err(err))
|
||||||
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func unsupportedBrowserScriptHandler(w http.ResponseWriter, r *http.Request) {
|
func unsupportedBrowserScriptHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user