mirror of
https://github.com/filebrowser/filebrowser.git
synced 2024-06-07 23:00:43 +00:00
30 lines
493 B
Go
30 lines
493 B
Go
|
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
|
||
|
}
|