2020-08-19 11:53:17 +00:00
|
|
|
package handler
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
2023-07-05 14:05:45 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-s3-gw/api/middleware"
|
2020-08-19 11:53:17 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func (h *handler) GetBucketLocationHandler(w http.ResponseWriter, r *http.Request) {
|
2024-10-25 01:36:18 +00:00
|
|
|
ctx := r.Context()
|
|
|
|
reqInfo := middleware.GetReqInfo(ctx)
|
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 {
|
2024-10-25 01:36:18 +00:00
|
|
|
h.logAndSendError(ctx, 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
|
|
|
|
2023-07-05 14:05:45 +00:00
|
|
|
if err = middleware.EncodeToResponse(w, LocationResponse{Location: bktInfo.LocationConstraint}); err != nil {
|
2024-10-25 01:36:18 +00:00
|
|
|
h.logAndSendError(ctx, w, "couldn't encode bucket location response", reqInfo, err)
|
2020-08-19 11:53:17 +00:00
|
|
|
}
|
|
|
|
}
|