summaryrefslogtreecommitdiffstats
path: root/web/static.go
diff options
context:
space:
mode:
Diffstat (limited to 'web/static.go')
-rw-r--r--web/static.go21
1 files changed, 3 insertions, 18 deletions
diff --git a/web/static.go b/web/static.go
index 7c1d37252..64d326e24 100644
--- a/web/static.go
+++ b/web/static.go
@@ -29,8 +29,8 @@ func (w *Web) InitStatic() {
mime.AddExtensionType(".wasm", "application/wasm")
- staticHandler := staticHandler(http.StripPrefix(path.Join(subpath, "static"), http.FileServer(http.Dir(staticDir))))
- pluginHandler := pluginHandler(w.App.Config, http.StripPrefix(path.Join(subpath, "static", "plugins"), http.FileServer(http.Dir(*w.App.Config().PluginSettings.ClientDirectory))))
+ staticHandler := staticFilesHandler(http.StripPrefix(path.Join(subpath, "static"), http.FileServer(http.Dir(staticDir))))
+ pluginHandler := staticFilesHandler(http.StripPrefix(path.Join(subpath, "static", "plugins"), http.FileServer(http.Dir(*w.App.Config().PluginSettings.ClientDirectory))))
if *w.App.Config().ServiceSettings.WebserverMode == "gzip" {
staticHandler = gziphandler.GzipHandler(staticHandler)
@@ -72,7 +72,7 @@ func root(c *Context, w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, filepath.Join(staticDir, "root.html"))
}
-func staticHandler(handler http.Handler) http.Handler {
+func staticFilesHandler(handler http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Cache-Control", "max-age=31556926, public")
if strings.HasSuffix(r.URL.Path, "/") {
@@ -82,18 +82,3 @@ func staticHandler(handler http.Handler) http.Handler {
handler.ServeHTTP(w, r)
})
}
-
-func pluginHandler(config model.ConfigFunc, handler http.Handler) http.Handler {
- return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- if *config().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)
- })
-}