2020-08-19 11:53:17 +00:00
|
|
|
package handler
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
2021-05-18 11:10:08 +00:00
|
|
|
"github.com/nspcc-dev/neofs-s3-gw/api"
|
2020-08-19 11:53:17 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func (h *handler) GetBucketLocationHandler(w http.ResponseWriter, r *http.Request) {
|
2021-08-05 09:18:52 +00:00
|
|
|
reqInfo := api.GetReqInfo(r.Context())
|
2020-08-19 11:53:17 +00:00
|
|
|
|
2022-03-18 13:04:09 +00:00
|
|
|
bktInfo, err := h.getBucketAndCheckOwner(r, reqInfo.BucketName)
|
2022-01-11 12:33:09 +00:00
|
|
|
if err != nil {
|
|
|
|
h.logAndSendError(w, "could not get bucket info", reqInfo, err)
|
2020-08-19 11:53:17 +00:00
|
|
|
return
|
2021-08-05 09:18:52 +00:00
|
|
|
}
|
2020-10-24 13:09:22 +00:00
|
|
|
|
2022-01-11 12:33:09 +00:00
|
|
|
if err = api.EncodeToResponse(w, LocationResponse{Location: bktInfo.LocationConstraint}); err != nil {
|
|
|
|
h.logAndSendError(w, "couldn't encode bucket location response", reqInfo, err)
|
2020-08-19 11:53:17 +00:00
|
|
|
}
|
|
|
|
}
|