From 186803472322d391ce6ff61a52aa15c9b014db90 Mon Sep 17 00:00:00 2001 From: Evgeniy Kulikov Date: Fri, 27 Nov 2020 15:32:52 +0300 Subject: [PATCH] Refactoring api/handler - don't require token.BearerToken - don't call `GetObjectInfo` Signed-off-by: Evgeniy Kulikov --- api/handler/list.go | 19 ------------------- api/handler/put.go | 14 -------------- 2 files changed, 33 deletions(-) diff --git a/api/handler/list.go b/api/handler/list.go index e10603009..5fd6247a1 100644 --- a/api/handler/list.go +++ b/api/handler/list.go @@ -5,9 +5,7 @@ import ( "strconv" "time" - sdk "github.com/nspcc-dev/cdn-neofs-sdk" "github.com/nspcc-dev/neofs-api-go/pkg/owner" - "github.com/nspcc-dev/neofs-api-go/pkg/token" "github.com/nspcc-dev/neofs-s3-gate/api" "github.com/nspcc-dev/neofs-s3-gate/api/layer" "go.uber.org/zap" @@ -29,27 +27,10 @@ func (h *handler) ListBucketsHandler(w http.ResponseWriter, r *http.Request) { var ( err error own = owner.NewID() - tkn *token.BearerToken res *ListBucketsResponse rid = api.GetRequestID(r.Context()) ) - if tkn, err = sdk.BearerToken(r.Context()); err != nil { - h.log.Error("something went wrong", - zap.String("request_id", rid), - zap.Error(err)) - - api.WriteErrorResponse(r.Context(), w, api.Error{ - Code: api.GetAPIError(api.ErrInternalError).Code, - Description: err.Error(), - HTTPStatusCode: http.StatusInternalServerError, - }, r.URL) - - return - } - - own = tkn.Issuer() - list, err := h.obj.ListBuckets(r.Context()) if err != nil { h.log.Error("something went wrong", diff --git a/api/handler/put.go b/api/handler/put.go index 835aa28d8..c65dcee45 100644 --- a/api/handler/put.go +++ b/api/handler/put.go @@ -30,20 +30,6 @@ func (h *handler) PutObjectHandler(w http.ResponseWriter, r *http.Request) { HTTPStatusCode: http.StatusBadRequest, }, r.URL) - return - } else if _, err = h.obj.GetObjectInfo(r.Context(), bkt, obj); err == nil { - h.log.Error("object exists", - zap.String("request_id", rid), - zap.String("bucket_name", bkt), - zap.String("object_name", obj), - zap.Error(err)) - - api.WriteErrorResponse(r.Context(), w, api.Error{ - Code: api.GetAPIError(api.ErrMethodNotAllowed).Code, - Description: "Object: " + bkt + "#" + obj + " already exists", - HTTPStatusCode: http.StatusBadRequest, - }, r.URL) - return }