Fix request body

This commit is contained in:
Viktor Patchev
2022-01-13 10:08:47 +01:00
parent 477d524cc3
commit cda87b7f77

View File

@@ -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",
})