filebrowser/setup.go
2016-06-25 21:57:10 +01:00

29 lines
603 B
Go

package filemanager
import (
"github.com/hacdias/caddy-filemanager/internal/config"
"github.com/mholt/caddy"
"github.com/mholt/caddy/caddyhttp/httpserver"
)
func init() {
caddy.RegisterPlugin("filemanager", caddy.Plugin{
ServerType: "http",
Action: setup,
})
}
// setup configures a new FileManager middleware instance.
func setup(c *caddy.Controller) error {
configs, err := config.Parse(c)
if err != nil {
return err
}
httpserver.GetConfig(c).AddMiddleware(func(next httpserver.Handler) httpserver.Handler {
return FileManager{Configs: configs, Next: next}
})
return nil
}