mirror of
https://github.com/FJurmanovic/wallet-go-api.git
synced 2026-02-06 06:08:16 +00:00
implemented wallet headers
This commit is contained in:
@@ -74,9 +74,9 @@ func (rc *AuthController) CheckToken(c *gin.Context) {
|
||||
token, _ := c.GetQuery("token")
|
||||
re := new(models.CheckToken)
|
||||
|
||||
valid, err := middleware.CheckToken(token)
|
||||
_, err := middleware.CheckToken(token)
|
||||
|
||||
if err != nil && valid.Valid {
|
||||
if err != nil {
|
||||
re.Valid = false
|
||||
c.AbortWithStatusJSON(400, re)
|
||||
}
|
||||
|
||||
35
pkg/controllers/wallets-header.go
Normal file
35
pkg/controllers/wallets-header.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"wallet-api/pkg/models"
|
||||
"wallet-api/pkg/services"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type WalletsHeaderController struct {
|
||||
WalletService *services.WalletService
|
||||
}
|
||||
|
||||
func NewWalletsHeaderController(as *services.WalletService, s *gin.RouterGroup) *WalletsHeaderController {
|
||||
wc := new(WalletsHeaderController)
|
||||
wc.WalletService = as
|
||||
|
||||
s.GET("", wc.Get)
|
||||
|
||||
return wc
|
||||
}
|
||||
|
||||
func (wc *WalletsHeaderController) Get(c *gin.Context) {
|
||||
body := new(models.Auth)
|
||||
|
||||
embed, _ := c.GetQuery("embed")
|
||||
walletId, _ := c.GetQuery("walletId")
|
||||
|
||||
auth := c.MustGet("auth")
|
||||
body.Id = auth.(*models.Auth).Id
|
||||
|
||||
wm := wc.WalletService.GetHeader(body, embed, walletId)
|
||||
|
||||
c.JSON(200, wm)
|
||||
}
|
||||
Reference in New Issue
Block a user