From 8efc842b595d303638e8524cfa41630be495bffd Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Mon, 8 Jun 2015 11:06:06 -0700 Subject: [PATCH] Add delete handlers and reply back as 'NotImplemented' instead of 404 --- pkg/api/api_object_handlers.go | 25 +++++++++++++++++++++---- pkg/api/api_router.go | 6 ++++++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/pkg/api/api_object_handlers.go b/pkg/api/api_object_handlers.go index d7e9aba3a..41f4e0aea 100644 --- a/pkg/api/api_object_handlers.go +++ b/pkg/api/api_object_handlers.go @@ -173,10 +173,6 @@ func (server *minioAPI) putObjectHandler(w http.ResponseWriter, req *http.Reques // as the minimum limit, they do not seem to enforce it one can successfully // create a 0byte file using a regular putObject() operation // - // For example take a look at :- - // - // $ mc ls https://s3.amazonaws.com/ferenginar/test.go - // // if isMinObjectSize(size) { // writeErrorResponse(w, req, EntityTooSmall, acceptsContentType, req.URL.Path) // return @@ -218,6 +214,9 @@ func (server *minioAPI) putObjectHandler(w http.ResponseWriter, req *http.Reques } } +/// Multipart API + +// New multipart upload func (server *minioAPI) newMultipartUploadHandler(w http.ResponseWriter, req *http.Request) { acceptsContentType := getContentType(req) // handle ACL's here at bucket level @@ -257,6 +256,7 @@ func (server *minioAPI) newMultipartUploadHandler(w http.ResponseWriter, req *ht } } +// Upload part func (server *minioAPI) putObjectPartHandler(w http.ResponseWriter, req *http.Request) { acceptsContentType := getContentType(req) // handle ACL's here at bucket level @@ -337,6 +337,7 @@ func (server *minioAPI) putObjectPartHandler(w http.ResponseWriter, req *http.Re } } +// Abort multipart upload func (server *minioAPI) abortMultipartUploadHandler(w http.ResponseWriter, req *http.Request) { acceptsContentType := getContentType(req) // handle ACL's here at bucket level @@ -369,6 +370,7 @@ func (server *minioAPI) abortMultipartUploadHandler(w http.ResponseWriter, req * } } +// List object parts func (server *minioAPI) listObjectPartsHandler(w http.ResponseWriter, req *http.Request) { acceptsContentType := getContentType(req) // handle ACL's here at bucket level @@ -408,6 +410,7 @@ func (server *minioAPI) listObjectPartsHandler(w http.ResponseWriter, req *http. } } +// Complete multipart upload func (server *minioAPI) completeMultipartUploadHandler(w http.ResponseWriter, req *http.Request) { acceptsContentType := getContentType(req) // handle ACL's here at bucket level @@ -460,3 +463,17 @@ func (server *minioAPI) completeMultipartUploadHandler(w http.ResponseWriter, re } } } + +/// Delete API + +// Delete bucket +func (server *minioAPI) deleteBucketHandler(w http.ResponseWriter, req *http.Request) { + error := getErrorCode(NotImplemented) + w.WriteHeader(error.HTTPStatusCode) +} + +// Delete object +func (server *minioAPI) deleteObjectHandler(w http.ResponseWriter, req *http.Request) { + error := getErrorCode(NotImplemented) + w.WriteHeader(error.HTTPStatusCode) +} diff --git a/pkg/api/api_router.go b/pkg/api/api_router.go index 5630dfb6d..7d6db5265 100644 --- a/pkg/api/api_router.go +++ b/pkg/api/api_router.go @@ -65,6 +65,12 @@ func HTTPHandler(config Config) http.Handler { mux.HandleFunc("/{bucket}/{object:.*}", api.getObjectHandler).Methods("GET") mux.HandleFunc("/{bucket}/{object:.*}", api.putObjectHandler).Methods("PUT") + // not implemented yet + mux.HandleFunc("/{bucket}", api.deleteBucketHandler).Methods("DELETE") + + // unsupported API + mux.HandleFunc("/{bucket}/{object:.*}", api.deleteObjectHandler).Methods("DELETE") + handler := validContentTypeHandler(mux) handler = timeValidityHandler(handler) handler = ignoreResourcesHandler(handler)