internal: add internal paths to HiddenFiles (#2133)

* Append Internal paths to Caddy config HiddenFiles

* gofmt

* Reuse a variable

* Update caddyhttp/internalsrv/setup.go

Co-Authored-By: magikstm <myskina@gmail.com>
This commit is contained in:
magikstm 2019-02-17 16:32:22 -05:00 committed by Matt Holt
parent 33b00dc8b1
commit 396d8e989f

View File

@ -33,7 +33,12 @@ func setup(c *caddy.Controller) error {
return err
}
httpserver.GetConfig(c).AddMiddleware(func(next httpserver.Handler) httpserver.Handler {
// Append Internal paths to Caddy config HiddenFiles to ensure
// files do not appear in Browse
config := httpserver.GetConfig(c)
config.HiddenFiles = append(config.HiddenFiles, paths...)
config.AddMiddleware(func(next httpserver.Handler) httpserver.Handler {
return Internal{Next: next, Paths: paths}
})