frostfs-s3-gw/api/handler/delete.go
Evgeniy Kulikov 9746978b1d Implement DeleteObject handler
Signed-off-by: Evgeniy Kulikov <kim@nspcc.ru>
2020-08-20 02:36:00 +03:00

36 lines
850 B
Go

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)
}