webdav: add DELETE support to server

This commit is contained in:
Simon Ser
2020-01-21 21:46:01 +01:00
parent 69f88b075a
commit 41b68829e8
5 changed files with 51 additions and 17 deletions

View File

@@ -76,8 +76,9 @@ func ServeMultistatus(w http.ResponseWriter, ms *Multistatus) error {
type Backend interface {
Options(r *http.Request) ([]string, error)
HeadGet(w http.ResponseWriter, r *http.Request) error
Put(r *http.Request) error
Propfind(r *http.Request, pf *Propfind, depth Depth) (*Multistatus, error)
Put(r *http.Request) error
Delete(r *http.Request) error
}
type Handler struct {
@@ -102,6 +103,12 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// TODO: Location if the server has mutated the href
w.WriteHeader(http.StatusCreated)
}
case http.MethodDelete:
// TODO: send a multistatus in case of partial failure
err = h.Backend.Delete(r)
if err == nil {
w.WriteHeader(http.StatusNoContent)
}
case "PROPFIND":
err = h.handlePropfind(w, r)
default: