filebrowser/setup.go

29 lines
594 B
Go
Raw Normal View History

2016-06-10 13:36:43 +00:00
package filemanager
import (
2016-06-28 09:24:02 +00:00
"github.com/hacdias/caddy-filemanager/config"
2016-06-10 13:36:43 +00:00
"github.com/mholt/caddy"
"github.com/mholt/caddy/caddyhttp/httpserver"
)
func init() {
caddy.RegisterPlugin("filemanager", caddy.Plugin{
ServerType: "http",
Action: setup,
})
}
2016-06-11 20:20:47 +00:00
// setup configures a new FileManager middleware instance.
2016-06-10 13:36:43 +00:00
func setup(c *caddy.Controller) error {
2016-06-25 20:57:10 +00:00
configs, err := config.Parse(c)
if err != nil {
return err
}
2016-06-10 13:36:43 +00:00
2016-06-22 20:30:40 +00:00
httpserver.GetConfig(c).AddMiddleware(func(next httpserver.Handler) httpserver.Handler {
2016-06-11 20:20:47 +00:00
return FileManager{Configs: configs, Next: next}
})
return nil
}