rename context to service

This commit is contained in:
kiwiidb
2022-01-19 13:53:40 +01:00
parent 9b1fd8255c
commit e22ab6ce49
8 changed files with 8 additions and 8 deletions

View File

@@ -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 {

View File

@@ -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"`

View File

@@ -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

View File

@@ -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 {

View File

@@ -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"`

View File

@@ -7,7 +7,7 @@ import (
"github.com/uptrace/bun"
)
type LndhubContext struct {
type LndhubService struct {
echo.Context
DB *bun.DB

View File

@@ -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

View File

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