2020-08-19 14:53:17 +03:00
|
|
|
package handler
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
2021-05-18 14:10:08 +03:00
|
|
|
"github.com/nspcc-dev/neofs-s3-gw/api"
|
2020-08-19 14:53:17 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
func (h *handler) GetBucketLocationHandler(w http.ResponseWriter, r *http.Request) {
|
2021-08-05 12:18:52 +03:00
|
|
|
reqInfo := api.GetReqInfo(r.Context())
|
2020-08-19 14:53:17 +03:00
|
|
|
|
2022-03-18 16:04:09 +03:00
|
|
|
bktInfo, err := h.getBucketAndCheckOwner(r, reqInfo.BucketName)
|
2022-01-11 15:33:09 +03:00
|
|
|
if err != nil {
|
|
|
|
h.logAndSendError(w, "could not get bucket info", reqInfo, err)
|
2020-08-19 14:53:17 +03:00
|
|
|
return
|
2021-08-05 12:18:52 +03:00
|
|
|
}
|
2020-10-24 16:09:22 +03:00
|
|
|
|
2022-01-11 15:33:09 +03: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 14:53:17 +03:00
|
|
|
}
|
|
|
|
}
|