mirror of
https://github.com/getAlby/lndhub.go.git
synced 2026-02-23 13:54:25 +01:00
Add payinvoice endpoint
This commit is contained in:
@@ -48,6 +48,7 @@ func main() {
|
||||
e.POST("/auth", controllers.AuthController{}.Auth)
|
||||
e.POST("/create", controllers.CreateUserController{}.CreateUser)
|
||||
e.POST("/addinvoice", controllers.AddInvoiceController{}.AddInvoice, middleware.JWT([]byte("secret")))
|
||||
e.POST("/payinvoice", controllers.PayInvoiceController{}.PayInvoice, middleware.JWT([]byte("secret")))
|
||||
|
||||
// Start server
|
||||
go func() {
|
||||
|
||||
32
pkg/controllers/payinvoice.ctrl.go
Normal file
32
pkg/controllers/payinvoice.ctrl.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// PayInvoiceController : Pay invoice controller struct
|
||||
type PayInvoiceController struct{}
|
||||
|
||||
// PayInvoice : Pay invoice Controller
|
||||
func (PayInvoiceController) PayInvoice(c echo.Context) error {
|
||||
var body struct {
|
||||
ID uint `json:"id"`
|
||||
Invoice string `json:"invoice" validate:"required"`
|
||||
Amount int `json:"amount" validate:"gt=0"`
|
||||
}
|
||||
|
||||
if err := c.Bind(&body); err != nil {
|
||||
return c.JSON(http.StatusBadRequest, echo.Map{
|
||||
"message": "failed to bind json",
|
||||
})
|
||||
}
|
||||
|
||||
if err := c.Validate(&body); err != nil {
|
||||
return c.JSON(http.StatusBadRequest, echo.Map{
|
||||
"message": "invalid request",
|
||||
})
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user