a399590204
Signed-off-by: Angira Kekteeva <kira@nspcc.ru>
42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
package handler
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gorilla/mux"
|
|
"github.com/nspcc-dev/neofs-s3-gw/api"
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
func (h *handler) GetBucketLocationHandler(w http.ResponseWriter, r *http.Request) {
|
|
var (
|
|
bkt = mux.Vars(r)["bucket"]
|
|
rid = api.GetRequestID(r.Context())
|
|
)
|
|
|
|
if _, err := h.obj.GetBucketInfo(r.Context(), bkt); 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
|
|
} else if err = api.EncodeToResponse(w, LocationResponse{Location: ""}); err != nil {
|
|
h.log.Error("could not write response",
|
|
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
|
|
}
|
|
}
|