diff --git a/api.go b/api.go index 8627d22c..403b3654 100644 --- a/api.go +++ b/api.go @@ -79,7 +79,7 @@ func resourceHandler(c *requestContext, w http.ResponseWriter, r *http.Request) case http.MethodPut: return putHandler(c, w, r) case http.MethodPost: - // Handle renaming + return postHandler(c, w, r) } /* // Execute beforeSave if it is a PUT request. @@ -211,6 +211,14 @@ func putHandler(c *requestContext, w http.ResponseWriter, r *http.Request) (int, return http.StatusOK, nil } +func postHandler(c *requestContext, w http.ResponseWriter, r *http.Request) (int, error) { + dst := r.Header.Get("Destination") + src := r.URL.Path + err := c.us.fileSystem.Rename(context.TODO(), src, dst) + + return errorToHTTP(err, true), err +} + // displayMode obtaisn the display mode from URL, or from the // cookie. func displayMode(w http.ResponseWriter, r *http.Request, scope string) string {