2019-12-16 06:43:00 -05:00
|
|
|
package controllers
|
|
|
|
|
|
|
|
import (
|
|
|
|
model "github.com/HFO4/cloudreve/models"
|
|
|
|
"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-16 23:02:50 -05:00
|
|
|
func init() {
|
|
|
|
handler = &webdav.Handler{
|
2019-12-16 06:43:00 -05:00
|
|
|
Prefix: "/dav/",
|
2019-12-16 23:02:50 -05:00
|
|
|
LockSystem: make(map[uint]webdav.LockSystem),
|
2019-12-16 06:43:00 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-16 23:02:50 -05:00
|
|
|
func ServeWebDAV(c *gin.Context) {
|
2019-12-16 06:43:00 -05:00
|
|
|
// 测试用user
|
2019-12-16 23:02:50 -05:00
|
|
|
user, _ := model.GetUserByID(1)
|
|
|
|
c.Set("user", &user)
|
|
|
|
fs, err := filesystem.NewFileSystemFromContext(c)
|
|
|
|
if err != nil {
|
|
|
|
util.Log().Panic("%s", err)
|
2019-12-16 06:43:00 -05:00
|
|
|
}
|
|
|
|
|
2019-12-16 23:02:50 -05:00
|
|
|
handler.ServeHTTP(c.Writer, c.Request, fs)
|
2019-12-16 06:43:00 -05:00
|
|
|
}
|