2019-12-16 19:43:00 +08:00
|
|
|
|
package controllers
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/HFO4/cloudreve/pkg/filesystem"
|
|
|
|
|
"github.com/HFO4/cloudreve/pkg/util"
|
|
|
|
|
"github.com/HFO4/cloudreve/pkg/webdav"
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var handler *webdav.Handler
|
|
|
|
|
|
2019-12-17 12:02:50 +08:00
|
|
|
|
func init() {
|
|
|
|
|
handler = &webdav.Handler{
|
2019-12-21 18:32:13 +08:00
|
|
|
|
Prefix: "/dav",
|
2019-12-17 12:02:50 +08:00
|
|
|
|
LockSystem: make(map[uint]webdav.LockSystem),
|
2019-12-16 19:43:00 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-21 18:32:13 +08:00
|
|
|
|
// ServeWebDAV 处理WebDAV相关请求
|
2019-12-17 12:02:50 +08:00
|
|
|
|
func ServeWebDAV(c *gin.Context) {
|
|
|
|
|
fs, err := filesystem.NewFileSystemFromContext(c)
|
|
|
|
|
if err != nil {
|
2019-12-21 18:32:13 +08:00
|
|
|
|
util.Log().Warning("无法为WebDAV初始化文件系统,%s", err)
|
|
|
|
|
return
|
2019-12-16 19:43:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-12-17 12:02:50 +08:00
|
|
|
|
handler.ServeHTTP(c.Writer, c.Request, fs)
|
2019-12-16 19:43:00 +08:00
|
|
|
|
}
|