Plugins: Serve static assets directly instead of through middleware handler (#32779)

* removed static routes from macaron

* move path src to plugins pkg

* use plugin details

* remove dead code

* fixes

* use clean from std lib

* reformat imports

* remove caching headers + add security checks

* revert using no cache header middleware

* add cache-control headers

* add 404 check

* use new var for subsequent file handling
This commit is contained in:
Will Browne
2021-04-21 15:17:23 +02:00
committed by GitHub
parent 7e2bf4f6c3
commit c37a3bebb7
4 changed files with 79 additions and 9 deletions
-6
View File
@@ -329,12 +329,6 @@ func (hs *HTTPServer) addMiddlewaresAndStaticRoutes() {
m.Use(middleware.Recovery(hs.Cfg))
for _, route := range hs.PluginManager.StaticRoutes() {
pluginRoute := path.Join("/public/plugins/", route.PluginId)
hs.log.Debug("Plugins: Adding route", "route", pluginRoute, "dir", route.Directory)
hs.mapStatic(m, route.Directory, "", pluginRoute)
}
hs.mapStatic(m, hs.Cfg.StaticRootPath, "build", "public/build")
hs.mapStatic(m, hs.Cfg.StaticRootPath, "", "public")
hs.mapStatic(m, hs.Cfg.StaticRootPath, "robots.txt", "robots.txt")