mirror of
https://github.com/getAlby/lndhub.go.git
synced 2026-02-15 01:44:23 +01:00
31
controllers/blank.ctrl.go
Normal file
31
controllers/blank.ctrl.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/getAlby/lndhub.go/lib/service"
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
// BlankController : Controller for endpoints that we do not support and simply return
|
||||
// a blank response for compatibility
|
||||
|
||||
// GetBtcController : GetBtcController struct
|
||||
type BlankController struct{}
|
||||
|
||||
func NewBlankController(svc *service.LndhubService) *BlankController {
|
||||
return &BlankController{}
|
||||
}
|
||||
|
||||
// We do NOT support onchain transactions thus we only return an empty array for backwards compatibility
|
||||
func (controller *BlankController) GetBtc(c echo.Context) error {
|
||||
addresses := []string{}
|
||||
|
||||
return c.JSON(http.StatusOK, &addresses)
|
||||
}
|
||||
|
||||
func (controller *BlankController) GetPending(c echo.Context) error {
|
||||
addresses := []string{}
|
||||
|
||||
return c.JSON(http.StatusOK, &addresses)
|
||||
}
|
||||
7
main.go
7
main.go
@@ -108,9 +108,11 @@ func main() {
|
||||
LndClient: &lndClient,
|
||||
}
|
||||
|
||||
// Public endpoints for account creation and authentication
|
||||
e.POST("/auth", controllers.NewAuthController(svc).Auth)
|
||||
e.POST("/create", controllers.NewCreateUserController(svc).CreateUser)
|
||||
|
||||
// Secured endpoints which require a Authorization token (JWT)
|
||||
secured := e.Group("", tokens.Middleware(c.JWTSecret))
|
||||
secured.POST("/addinvoice", controllers.NewAddInvoiceController(svc).AddInvoice)
|
||||
secured.POST("/payinvoice", controllers.NewPayInvoiceController(svc).PayInvoice)
|
||||
@@ -119,6 +121,11 @@ func main() {
|
||||
secured.GET("/balance", controllers.NewBalanceController(svc).Balance)
|
||||
secured.GET("/getinfo", controllers.NewGetInfoController(svc).GetInfo)
|
||||
|
||||
// These endpoints are not supported and we return a blank response for backwards compatibility
|
||||
blankController := controllers.NewBlankController(svc)
|
||||
secured.GET("/getbtc", blankController.GetBtc)
|
||||
secured.GET("/getpending", blankController.GetPending)
|
||||
|
||||
// Start server
|
||||
go func() {
|
||||
if err := e.Start(":3000"); err != nil && err != http.ErrServerClosed {
|
||||
|
||||
Reference in New Issue
Block a user