forked from TrueCloudLab/frostfs-s3-gw
41 lines
1 KiB
Go
41 lines
1 KiB
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) 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)
|
||
|
}
|
||
|
}
|