From cda87b7f77e76ddf7c831d53be58a163659c9ec6 Mon Sep 17 00:00:00 2001 From: Viktor Patchev Date: Thu, 13 Jan 2022 10:08:47 +0100 Subject: [PATCH] Fix request body --- pkg/controllers/payinvoice.ctrl.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pkg/controllers/payinvoice.ctrl.go b/pkg/controllers/payinvoice.ctrl.go index 169c881..bc3508c 100644 --- a/pkg/controllers/payinvoice.ctrl.go +++ b/pkg/controllers/payinvoice.ctrl.go @@ -10,19 +10,18 @@ type PayInvoiceController struct{} // PayInvoice : Pay invoice Controller func (PayInvoiceController) PayInvoice(c echo.Context) error { - var body struct { - ID uint `json:"id"` + var reqBody struct { Invoice string `json:"invoice" validate:"required"` Amount int `json:"amount" validate:"gt=0"` } - if err := c.Bind(&body); err != nil { + if err := c.Bind(&reqBody); err != nil { return c.JSON(http.StatusBadRequest, echo.Map{ "message": "failed to bind json", }) } - if err := c.Validate(&body); err != nil { + if err := c.Validate(&reqBody); err != nil { return c.JSON(http.StatusBadRequest, echo.Map{ "message": "invalid request", })