From 15f997faf0ff629d8da490c52c023e68a2eb7154 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Sun, 2 Jul 2017 18:16:02 +0100 Subject: [PATCH] post Former-commit-id: f8355933ef7878ec9120a615cdbb5c212583bc86 [formerly f46e21a47ed05f968bab1a77a8fe291b44c5f7c7] [formerly 4cacf04503d5aadb4ef620ed039dbf8a3a91c4a4 [formerly 1d235c9852cf7bf7f93dab3edb2264965787d28e]] Former-commit-id: 27158f0c815dd3160768253a38d02712f01c90ef [formerly be1a5d2cbcf867c7292cd58ee66cfb42c55cfc41] Former-commit-id: eb527d245318ce88f358964b0b3dff8d9e4a9ffd --- api.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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 {