mirror of
https://github.com/getAlby/lndhub.go.git
synced 2025-12-24 08:05:02 +01:00
rename context to service
This commit is contained in:
@@ -16,7 +16,7 @@ type AddInvoiceController struct{}
|
||||
|
||||
// AddInvoice : Add invoice Controller
|
||||
func (AddInvoiceController) AddInvoice(c echo.Context) error {
|
||||
ctx := c.(*lib.LndhubContext)
|
||||
ctx := c.(*lib.LndhubService)
|
||||
user := ctx.User
|
||||
|
||||
type RequestBody struct {
|
||||
|
||||
@@ -19,7 +19,7 @@ type AuthController struct {
|
||||
|
||||
// Auth : Auth Controller
|
||||
func (ctrl AuthController) Auth(c echo.Context) error {
|
||||
ctx := c.(*lib.LndhubContext)
|
||||
ctx := c.(*lib.LndhubService)
|
||||
type RequestBody struct {
|
||||
Login string `json:"login"`
|
||||
Password string `json:"password"`
|
||||
|
||||
@@ -13,7 +13,7 @@ type BalanceController struct{}
|
||||
|
||||
// Balance : Balance Controller
|
||||
func (BalanceController) Balance(c echo.Context) error {
|
||||
ctx := c.(*lib.LndhubContext)
|
||||
ctx := c.(*lib.LndhubService)
|
||||
c.Logger().Warn(ctx.User.ID)
|
||||
|
||||
db := ctx.DB
|
||||
|
||||
@@ -21,7 +21,7 @@ type CreateUserController struct{}
|
||||
|
||||
// CreateUser : Create user Controller
|
||||
func (CreateUserController) CreateUser(c echo.Context) error {
|
||||
ctx := c.(*lib.LndhubContext)
|
||||
ctx := c.(*lib.LndhubService)
|
||||
|
||||
// optional parameters that we currently do not use
|
||||
type RequestBody struct {
|
||||
|
||||
@@ -14,7 +14,7 @@ type PayInvoiceController struct{}
|
||||
|
||||
// PayInvoice : Pay invoice Controller
|
||||
func (PayInvoiceController) PayInvoice(c echo.Context) error {
|
||||
ctx := c.(*lib.LndhubContext)
|
||||
ctx := c.(*lib.LndhubService)
|
||||
var reqBody struct {
|
||||
Invoice string `json:"invoice" validate:"required"`
|
||||
Amount int `json:"amount" validate:"omitempty,gte=0"`
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"github.com/uptrace/bun"
|
||||
)
|
||||
|
||||
type LndhubContext struct {
|
||||
type LndhubService struct {
|
||||
echo.Context
|
||||
|
||||
DB *bun.DB
|
||||
|
||||
@@ -48,7 +48,7 @@ func Middleware(secret []byte) echo.MiddlewareFunc {
|
||||
func UserMiddleware(db *bun.DB) echo.MiddlewareFunc {
|
||||
return func(next echo.HandlerFunc) echo.HandlerFunc {
|
||||
return func(c echo.Context) error {
|
||||
ctx := c.(*lib.LndhubContext)
|
||||
ctx := c.(*lib.LndhubService)
|
||||
userId := c.Get("UserID")
|
||||
|
||||
var user models.User
|
||||
|
||||
2
main.go
2
main.go
@@ -115,7 +115,7 @@ func main() {
|
||||
// Initialize a custom context with
|
||||
e.Use(func(next echo.HandlerFunc) echo.HandlerFunc {
|
||||
return func(c echo.Context) error {
|
||||
cc := &lib.LndhubContext{Context: c, DB: dbConn, LndClient: &lndClient}
|
||||
cc := &lib.LndhubService{Context: c, DB: dbConn, LndClient: &lndClient}
|
||||
return next(cc)
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user