Files
filebrowser/setup.go
T

29 lines
594 B
Go
Raw Normal View History

2016-06-10 14:36:43 +01:00
package filemanager
import (
2016-06-28 10:24:02 +01:00
"github.com/hacdias/caddy-filemanager/config"
2016-06-10 14:36:43 +01: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 21:20:47 +01:00
// setup configures a new FileManager middleware instance.
2016-06-10 14:36:43 +01:00
func setup(c *caddy.Controller) error {
2016-06-25 21:57:10 +01:00
configs, err := config.Parse(c)
2016-06-10 18:27:27 +01:00
if err != nil {
return err
}
2016-06-10 14:36:43 +01:00
2016-06-22 21:30:40 +01:00
httpserver.GetConfig(c).AddMiddleware(func(next httpserver.Handler) httpserver.Handler {
2016-06-11 21:20:47 +01:00
return FileManager{Configs: configs, Next: next}
2016-06-10 18:27:27 +01:00
})
return nil
}