mirror of
https://github.com/getAlby/lndhub.go.git
synced 2025-12-23 07:35:04 +01:00
* remove cmd folder as we are going to have only one entrypoint * get rid of pkg directory * rename test -> integration_tests as unit tests should reside next to the actual files they are testing * database migration WIP * reinstate gorm boilerplate in the addinvoice for now to make it compile * introduce migrations * add Makefile * don't use unsigned types for database mappings * migrations work now * add build target * use echo groups * gorm removed * add envconfig * fix comments
33 lines
688 B
Go
33 lines
688 B
Go
package controllers
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/labstack/echo/v4"
|
|
)
|
|
|
|
// PayInvoiceController : Pay invoice controller struct
|
|
type PayInvoiceController struct{}
|
|
|
|
// PayInvoice : Pay invoice Controller
|
|
func (PayInvoiceController) PayInvoice(c echo.Context) error {
|
|
var reqBody struct {
|
|
Invoice string `json:"invoice" validate:"required"`
|
|
Amount int `json:"amount" validate:"gt=0"`
|
|
}
|
|
|
|
if err := c.Bind(&reqBody); err != nil {
|
|
return c.JSON(http.StatusBadRequest, echo.Map{
|
|
"message": "failed to bind json",
|
|
})
|
|
}
|
|
|
|
if err := c.Validate(&reqBody); err != nil {
|
|
return c.JSON(http.StatusBadRequest, echo.Map{
|
|
"message": "invalid request",
|
|
})
|
|
}
|
|
|
|
return nil
|
|
}
|