2021-03-01 18:04:59 +00:00
|
|
|
package webdav
|
|
|
|
|
|
|
|
import (
|
2021-11-29 10:07:54 +00:00
|
|
|
"net/http"
|
|
|
|
|
2021-03-01 18:04:59 +00:00
|
|
|
"github.com/distribyted/distribyted/fs"
|
2021-11-29 10:07:54 +00:00
|
|
|
"github.com/rs/zerolog/log"
|
2021-03-01 18:04:59 +00:00
|
|
|
"golang.org/x/net/webdav"
|
|
|
|
)
|
|
|
|
|
2021-04-04 17:24:58 +00:00
|
|
|
func newHandler(fs fs.Filesystem) *webdav.Handler {
|
2021-11-29 10:07:54 +00:00
|
|
|
l := log.Logger.With().Str("component", "webDAV").Logger()
|
2021-03-01 18:04:59 +00:00
|
|
|
return &webdav.Handler{
|
|
|
|
Prefix: "/",
|
2021-04-04 17:24:58 +00:00
|
|
|
FileSystem: newFS(fs),
|
2021-03-01 18:04:59 +00:00
|
|
|
LockSystem: webdav.NewMemLS(),
|
2021-11-29 10:07:54 +00:00
|
|
|
Logger: func(req *http.Request, err error) {
|
|
|
|
if err != nil {
|
|
|
|
l.Error().Err(err).Str("path", req.RequestURI).Msg("webDAV error")
|
|
|
|
}
|
|
|
|
},
|
2021-03-01 18:04:59 +00:00
|
|
|
}
|
|
|
|
}
|