fix(benefactor): fix path parameter binding in kind box request GetByID handler

This commit is contained in:
Erfan Mohammadi 2024-04-27 03:25:26 +03:30 committed by Alireza Mokhtari Garakani
parent d405c01b7b
commit 9de9fc8e45
1 changed files with 5 additions and 1 deletions

View File

@ -1,6 +1,7 @@
package benefactorkindboxreqhandler package benefactorkindboxreqhandler
import ( import (
"git.gocasts.ir/ebhomengo/niki/pkg/claim"
"net/http" "net/http"
param "git.gocasts.ir/ebhomengo/niki/param/benefactor/kind_box_req" param "git.gocasts.ir/ebhomengo/niki/param/benefactor/kind_box_req"
@ -10,9 +11,12 @@ import (
func (h Handler) Get(c echo.Context) error { func (h Handler) Get(c echo.Context) error {
var req param.KindBoxReqGetRequest var req param.KindBoxReqGetRequest
if bErr := c.Bind(&req); bErr != nil { if bErr := echo.PathParamsBinder(c).Uint("id", &req.KindBoxReqID).BindError(); bErr != nil {
return echo.NewHTTPError(http.StatusBadRequest) return echo.NewHTTPError(http.StatusBadRequest)
} }
claims := claim.GetClaimsFromEchoContext(c)
req.BenefactorID = claims.UserID
if fieldErrors, err := h.benefactorKindBoxReqVld.ValidateGetRequest(req); err != nil { if fieldErrors, err := h.benefactorKindBoxReqVld.ValidateGetRequest(req); err != nil {
msg, code := httpmsg.Error(err) msg, code := httpmsg.Error(err)