MCPcopy Create free account
hub / github.com/cloudreve/cloudreve / ServeHTTP

Function ServeHTTP

pkg/webdav/webdav.go:55–95  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

53}
54
55func ServeHTTP(c *gin.Context) {
56 dep := dependency.FromContext(c)
57 u := inventory.UserFromContext(c)
58 fm := manager.NewFileManager(dep, u)
59 defer fm.Recycle()
60
61 status, err := http.StatusBadRequest, errUnsupportedMethod
62
63 switch c.Request.Method {
64 case "OPTIONS":
65 status, err = handleOptions(c, u, fm)
66 case "GET", "HEAD", "POST":
67 status, err = handleGetHeadPost(c, u, fm)
68 case "DELETE":
69 status, err = handleDelete(c, u, fm)
70 case "PUT":
71 status, err = handlePut(c, u, fm)
72 case "MKCOL":
73 status, err = handleMkcol(c, u, fm)
74 case "COPY", "MOVE":
75 status, err = handleCopyMove(c, u, fm)
76 case "LOCK":
77 status, err = handleLock(c, u, fm)
78 case "UNLOCK":
79 status, err = handleUnlock(c, u, fm)
80 case "PROPFIND":
81 status, err = handlePropfind(c, u, fm)
82 case "PROPPATCH":
83 status, err = handleProppatch(c, u, fm)
84 }
85 if status != 0 {
86 c.Writer.WriteHeader(status)
87 if status != http.StatusNoContent {
88 c.Writer.Write([]byte(StatusText(status)))
89 }
90 }
91
92 if err != nil {
93 dep.Logger().Debug("WebDAV request failed with error: %s", err)
94 }
95}
96
97func confirmLock(c *gin.Context, fm manager.FileManager, user *ent.User, srcAnc, dstAnc fs.File, src, dst *fs.URI) (func(), fs.LockSession, int, error) {
98 hdr := c.Request.Header.Get("If")

Callers

nothing calls this directly

Calls 15

RecycleMethod · 0.95
FromContextFunction · 0.92
UserFromContextFunction · 0.92
NewFileManagerFunction · 0.92
handleOptionsFunction · 0.85
handleGetHeadPostFunction · 0.85
handleDeleteFunction · 0.85
handlePutFunction · 0.85
handleMkcolFunction · 0.85
handleCopyMoveFunction · 0.85
handleLockFunction · 0.85
handleUnlockFunction · 0.85

Tested by

no test coverage detected