mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
Modify: add fs into webdav
This commit is contained in:
31
routers/controllers/webdav.go
Normal file
31
routers/controllers/webdav.go
Normal file
@@ -0,0 +1,31 @@
|
||||
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
|
||||
|
||||
func init(){
|
||||
handler = &webdav.Handler{
|
||||
Prefix: "/dav/",
|
||||
FileSystem: webdav.AdapterFS(""),
|
||||
LockSystem: webdav.NewMemLS(),
|
||||
}
|
||||
}
|
||||
|
||||
func ServeWebDAV(c *gin.Context){
|
||||
// 测试用user
|
||||
user,_ := model.GetUserByID(1)
|
||||
c.Set("user",&user)
|
||||
fs,err := filesystem.NewFileSystemFromContext(c)
|
||||
if err != nil{
|
||||
util.Log().Panic("%s",err)
|
||||
}
|
||||
|
||||
handler.ServeHTTP(c.Writer,c.Request,fs)
|
||||
}
|
||||
Reference in New Issue
Block a user