niki/delivery/http_server/benefactor/address/get_all.go

36 lines
936 B
Go
Raw Normal View History

package benefactoraddresshandler
import (
"net/http"
param "git.gocasts.ir/ebhomengo/niki/param/benefactor/address"
"git.gocasts.ir/ebhomengo/niki/pkg/claim"
httpmsg "git.gocasts.ir/ebhomengo/niki/pkg/http_msg"
"github.com/labstack/echo/v4"
)
// GetAddresses godoc
// @Summary Get all benefactor addresses
// @Tags Address
// @Accept json
// @Produce json
// @Success 200 {object} param.GetAllAddressesResponse
// @Failure 400 {string} "Bad request"
// @Security AuthBearerBenefactor
2024-06-14 08:41:36 +00:00
// @Router /address/ [get].
func (h Handler) GetAddresses(c echo.Context) error {
var req param.GetAllAddressesRequest
claims := claim.GetClaimsFromEchoContext(c)
req.BenefactorID = claims.UserID
resp, sErr := h.addressSvc.GetAll(c.Request().Context(), req)
if sErr != nil {
msg, code := httpmsg.Error(sErr)
return echo.NewHTTPError(code, msg)
}
return c.JSON(http.StatusOK, resp)
}