From 92b039fa5e3a44e0caa5905be585e9abecfe9f6f Mon Sep 17 00:00:00 2001 From: Evgeniy Kulikov Date: Wed, 19 Aug 2020 14:52:44 +0300 Subject: [PATCH] Add unsupported handlers Signed-off-by: Evgeniy Kulikov --- api/handler/api.go | 2 ++ api/handler/not-support.go | 72 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 api/handler/not-support.go diff --git a/api/handler/api.go b/api/handler/api.go index 9499fca1..bdea9147 100644 --- a/api/handler/api.go +++ b/api/handler/api.go @@ -20,6 +20,8 @@ type ( } ) +const notSupported = "Not supported by NeoFS S3 Gate: " + var _ api.Handler = (*handler)(nil) func New(log *zap.Logger, obj layer.Client) (api.Handler, error) { diff --git a/api/handler/not-support.go b/api/handler/not-support.go new file mode 100644 index 00000000..f5795eb0 --- /dev/null +++ b/api/handler/not-support.go @@ -0,0 +1,72 @@ +package handler + +import ( + "net/http" + + "github.com/gorilla/mux" + "github.com/nspcc-dev/neofs-s3-gate/api" +) + +func (h *handler) DeleteBucketHandler(w http.ResponseWriter, r *http.Request) { + api.WriteErrorResponse(r.Context(), w, api.Error{ + Code: api.GetAPIError(api.ErrBadRequest).Code, + Description: notSupported + mux.CurrentRoute(r).GetName(), + HTTPStatusCode: http.StatusNotImplemented, + }, r.URL) +} + +func (h *handler) DeleteBucketPolicyHandler(w http.ResponseWriter, r *http.Request) { + api.WriteErrorResponse(r.Context(), w, api.Error{ + Code: api.GetAPIError(api.ErrBadRequest).Code, + Description: notSupported + mux.CurrentRoute(r).GetName(), + HTTPStatusCode: http.StatusNotImplemented, + }, r.URL) +} + +func (h *handler) DeleteBucketLifecycleHandler(w http.ResponseWriter, r *http.Request) { + api.WriteErrorResponse(r.Context(), w, api.Error{ + Code: api.GetAPIError(api.ErrBadRequest).Code, + Description: notSupported + mux.CurrentRoute(r).GetName(), + HTTPStatusCode: http.StatusNotImplemented, + }, r.URL) +} + +func (h *handler) DeleteBucketEncryptionHandler(w http.ResponseWriter, r *http.Request) { + api.WriteErrorResponse(r.Context(), w, api.Error{ + Code: api.GetAPIError(api.ErrBadRequest).Code, + Description: notSupported + mux.CurrentRoute(r).GetName(), + HTTPStatusCode: http.StatusNotImplemented, + }, r.URL) +} + +func (h *handler) PutBucketTaggingHandler(w http.ResponseWriter, r *http.Request) { + api.WriteErrorResponse(r.Context(), w, api.Error{ + Code: api.GetAPIError(api.ErrBadRequest).Code, + Description: notSupported + mux.CurrentRoute(r).GetName(), + HTTPStatusCode: http.StatusNotImplemented, + }, r.URL) +} + +func (h *handler) PutBucketVersioningHandler(w http.ResponseWriter, r *http.Request) { + api.WriteErrorResponse(r.Context(), w, api.Error{ + Code: api.GetAPIError(api.ErrBadRequest).Code, + Description: notSupported + mux.CurrentRoute(r).GetName(), + HTTPStatusCode: http.StatusNotImplemented, + }, r.URL) +} + +func (h *handler) PutBucketNotificationHandler(w http.ResponseWriter, r *http.Request) { + api.WriteErrorResponse(r.Context(), w, api.Error{ + Code: api.GetAPIError(api.ErrBadRequest).Code, + Description: notSupported + mux.CurrentRoute(r).GetName(), + HTTPStatusCode: http.StatusNotImplemented, + }, r.URL) +} + +func (h *handler) PutBucketHandler(w http.ResponseWriter, r *http.Request) { + api.WriteErrorResponse(r.Context(), w, api.Error{ + Code: api.GetAPIError(api.ErrBadRequest).Code, + Description: notSupported + mux.CurrentRoute(r).GetName(), + HTTPStatusCode: http.StatusNotImplemented, + }, r.URL) +}