[MM-45309] Replace github.com/mattermost/gziphandler with github.com/klauspost/compress/gzhttp (#24293)

Этот коммит содержится в:
Ben Schumacher
2023-10-12 08:27:31 +02:00
коммит произвёл GitHub
родитель eb35e83152
Коммит e4fa6200c3
6 изменённых файлов: 19 добавлений и 24 удалений

Просмотреть файл

@@ -14,12 +14,11 @@ import (
"strings"
"time"
"github.com/klauspost/compress/gzhttp"
"github.com/opentracing/opentracing-go"
"github.com/opentracing/opentracing-go/ext"
spanlog "github.com/opentracing/opentracing-go/log"
"github.com/mattermost/gziphandler"
"github.com/mattermost/mattermost/server/public/model"
"github.com/mattermost/mattermost/server/public/shared/i18n"
"github.com/mattermost/mattermost/server/public/shared/mlog"
@@ -474,7 +473,7 @@ func (w *Web) APIHandler(h func(*Context, http.ResponseWriter, *http.Request)) h
IsLocal: false,
}
if *w.srv.Config().ServiceSettings.WebserverMode == "gzip" {
return gziphandler.GzipHandler(handler)
return gzhttp.GzipHandler(handler)
}
return handler
}
@@ -494,7 +493,7 @@ func (w *Web) APIHandlerTrustRequester(h func(*Context, http.ResponseWriter, *ht
IsLocal: false,
}
if *w.srv.Config().ServiceSettings.WebserverMode == "gzip" {
return gziphandler.GzipHandler(handler)
return gzhttp.GzipHandler(handler)
}
return handler
}
@@ -513,7 +512,7 @@ func (w *Web) APISessionRequired(h func(*Context, http.ResponseWriter, *http.Req
IsLocal: false,
}
if *w.srv.Config().ServiceSettings.WebserverMode == "gzip" {
return gziphandler.GzipHandler(handler)
return gzhttp.GzipHandler(handler)
}
return handler
}

Просмотреть файл

@@ -13,7 +13,7 @@ import (
"path/filepath"
"strings"
"github.com/mattermost/gziphandler"
"github.com/klauspost/compress/gzhttp"
"github.com/mattermost/mattermost/server/public/model"
"github.com/mattermost/mattermost/server/public/shared/mlog"
@@ -39,8 +39,8 @@ func (w *Web) InitStatic() {
pluginHandler := staticFilesHandler(http.StripPrefix(path.Join(subpath, "static", "plugins"), http.FileServer(http.Dir(*w.srv.Config().PluginSettings.ClientDirectory))))
if *w.srv.Config().ServiceSettings.WebserverMode == "gzip" {
staticHandler = gziphandler.GzipHandler(staticHandler)
pluginHandler = gziphandler.GzipHandler(pluginHandler)
staticHandler = gzhttp.GzipHandler(staticHandler)
pluginHandler = gzhttp.GzipHandler(pluginHandler)
}
w.MainRouter.PathPrefix("/static/plugins/").Handler(pluginHandler)