add base code
This commit is contained in:
29
setup.go
Normal file
29
setup.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package filemanager
|
||||
|
||||
import (
|
||||
"github.com/mholt/caddy"
|
||||
"github.com/mholt/caddy/caddyhttp/httpserver"
|
||||
)
|
||||
|
||||
func init() {
|
||||
caddy.RegisterPlugin("filemanager", caddy.Plugin{
|
||||
ServerType: "http",
|
||||
Action: setup,
|
||||
})
|
||||
}
|
||||
|
||||
// setup configures the middlware.
|
||||
func setup(c *caddy.Controller) error {
|
||||
cnf := httpserver.GetConfig(c.Key)
|
||||
|
||||
// parse config
|
||||
|
||||
mid := func(next httpserver.Handler) httpserver.Handler {
|
||||
return FileManager{
|
||||
Next: next,
|
||||
}
|
||||
}
|
||||
|
||||
cnf.AddMiddleware(mid)
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user