PLT-7622 Improvements to server handling of webapp plugins (#7445)
* Improvements to server handling of webapp plugins * Fix newline * Update manifest function names
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
2a6cd44f23
Коммит
2628022275
26
web/web.go
26
web/web.go
@@ -26,12 +26,17 @@ func InitWeb() {
|
||||
if *utils.Cfg.ServiceSettings.WebserverMode != "disabled" {
|
||||
staticDir, _ := utils.FindDir(model.CLIENT_DIR)
|
||||
l4g.Debug("Using client directory at %v", staticDir)
|
||||
|
||||
staticHandler := staticHandler(http.StripPrefix("/static/", http.FileServer(http.Dir(staticDir))))
|
||||
pluginHandler := pluginHandler(http.StripPrefix("/static/plugins/", http.FileServer(http.Dir(staticDir+"plugins/"))))
|
||||
|
||||
if *utils.Cfg.ServiceSettings.WebserverMode == "gzip" {
|
||||
mainrouter.PathPrefix("/static/").Handler(gziphandler.GzipHandler(staticHandler(http.StripPrefix("/static/", http.FileServer(http.Dir(staticDir))))))
|
||||
} else {
|
||||
mainrouter.PathPrefix("/static/").Handler(staticHandler(http.StripPrefix("/static/", http.FileServer(http.Dir(staticDir)))))
|
||||
staticHandler = gziphandler.GzipHandler(staticHandler)
|
||||
pluginHandler = gziphandler.GzipHandler(pluginHandler)
|
||||
}
|
||||
|
||||
mainrouter.PathPrefix("/static/plugins/").Handler(pluginHandler)
|
||||
mainrouter.PathPrefix("/static/").Handler(staticHandler)
|
||||
mainrouter.Handle("/{anything:.*}", api.AppHandlerIndependent(root)).Methods("GET")
|
||||
}
|
||||
}
|
||||
@@ -47,6 +52,21 @@ func staticHandler(handler http.Handler) http.Handler {
|
||||
})
|
||||
}
|
||||
|
||||
func pluginHandler(handler http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if *utils.Cfg.ServiceSettings.EnableDeveloper {
|
||||
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
|
||||
} else {
|
||||
w.Header().Set("Cache-Control", "max-age=31556926, public")
|
||||
}
|
||||
if strings.HasSuffix(r.URL.Path, "/") {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
handler.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
|
||||
//map should be of minimum required browser version.
|
||||
//var browsersNotSupported string = "MSIE/11;Internet Explorer/11;Safari/9;Chrome/43;Edge/15;Firefox/52"
|
||||
//var browserMinimumSupported = [6]string{"MSIE/11", "Internet Explorer/11", "Safari/9", "Chrome/43", "Edge/15", "Firefox/52"}
|
||||
|
||||
Ссылка в новой задаче
Block a user