From 9746978b1d555ff2d1c596ac7a31820dd372758f Mon Sep 17 00:00:00 2001 From: Evgeniy Kulikov Date: Thu, 20 Aug 2020 02:36:00 +0300 Subject: [PATCH] Implement DeleteObject handler Signed-off-by: Evgeniy Kulikov --- api/handler/delete.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 api/handler/delete.go diff --git a/api/handler/delete.go b/api/handler/delete.go new file mode 100644 index 00000000..1798317b --- /dev/null +++ b/api/handler/delete.go @@ -0,0 +1,36 @@ +package handler + +import ( + "net/http" + + "github.com/gorilla/mux" + "github.com/nspcc-dev/neofs-s3-gate/api" + "go.uber.org/zap" +) + +func (h *handler) DeleteObjectHandler(w http.ResponseWriter, r *http.Request) { + var ( + req = mux.Vars(r) + bkt = req["bucket"] + obj = req["object"] + rid = api.GetRequestID(r.Context()) + ) + + if err := h.obj.DeleteObject(r.Context(), bkt, obj); err != nil { + h.log.Error("could not delete object", + zap.String("request_id", rid), + zap.String("bucket_name", bkt), + zap.String("object_name", obj), + zap.Error(err)) + + // Ignore delete errors: + + // api.WriteErrorResponse(r.Context(), w, api.Error{ + // Code: api.GetAPIError(api.ErrInternalError).Code, + // Description: err.Error(), + // HTTPStatusCode: http.StatusInternalServerError, + // }, r.URL) + } + + w.WriteHeader(http.StatusNoContent) +}