Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetUserFromContext ¶
GetUserFromContext retrieves the user ID from the context, if available, and returns it as a UUID pointer. If the user ID is not present in the context, or if it is invalid, appropriate error responses are sent back to the client and nil is returned.
Parameters:
- ctx: The Gin context from which to retrieve the user ID.
Returns:
A pointer to the UUID representing the user's ID, or nil if the ID was not found or could not be parsed.
Types ¶
type BaseController ¶
type BaseController interface { // GetRoute provides the base route path for the controller. // This path serves as the primary endpoint for all routes within the controller. GetRoute() string // InitRoute sets up and initializes all routes for the controller within the specified // Gin router group. It returns the updated router group containing the controller’s configured routes. InitRoute(route *gin.RouterGroup) *gin.RouterGroup }
BaseController defines a fundamental interface for controllers, offering essential methods for retrieving and initializing routes within a Gin router group.
type SlotController ¶
type SlotController struct {
// contains filtered or unexported fields
}
SlotController manages slot game operations, including processing spin requests and retrieving user spin history. It connects to slotService for core operations and applies JWT authentication for protected routes.
func NewSlotController ¶
func NewSlotController(config *server.APIConfig, appConfig *config.SlotConfig, redisClient *libredis.Client, slotService interfaces.ISlotService) *SlotController
NewSlotController initializes a new SlotController with the provided configuration and slotService, establishing the required dependencies for handling slot game operations.
Parameters:
- config: A pointer to the API configuration struct.
- slotService: An implementation of the ISlotService interface for slot game functionality.
Returns:
A pointer to a SlotController instance.
func (*SlotController) GetRoute ¶
func (c *SlotController) GetRoute() string
GetRoute returns the base route path for SlotController, serving as the primary API route for all slot game endpoints.
func (*SlotController) InitRoute ¶
func (c *SlotController) InitRoute(route *gin.RouterGroup) *gin.RouterGroup
InitRoute registers the slot game routes under the "/slot" endpoint, applying JWT middleware for authentication. Routes include "/spin" for spinning and "/history" for retrieving the user's spin history.
Parameters:
- route: A Gin RouterGroup to which the slot game routes will be added.
Returns:
An updated RouterGroup with initialized slot game routes.
type StatusController ¶
type StatusController struct{}
StatusController is a simple controller that handles server status checks, providing a health check endpoint to verify that the server is up and running.
func NewStatusController ¶
func NewStatusController() *StatusController
NewStatusController creates a new instance of StatusController. This function provides a lightweight, easily initialized controller for handling server status requests.
Returns:
A pointer to a StatusController instance.
func (*StatusController) GetRoute ¶
func (c *StatusController) GetRoute() string
GetRoute returns the base route path for the StatusController. This path provides the main API route for server status checks.
func (*StatusController) InitRoute ¶
func (c *StatusController) InitRoute(route *gin.RouterGroup) *gin.RouterGroup
InitRoute sets up the status check route under "/status", which responds with a success message. This route allows clients to confirm that the server is operational.
Parameters:
- route: A Gin RouterGroup to which the status check route will be added.
Returns:
An updated RouterGroup with the status route initialized.
type UserController ¶
type UserController struct {
// contains filtered or unexported fields
}
UserController manages user-related actions, including registration, login, and profile retrieval. It connects to userService for core user operations and uses JWT authentication for protected routes.
func NewUserController ¶
func NewUserController(userService interfaces.IUserService, config *server.APIConfig) *UserController
NewUserController creates a new instance of UserController with the given userService and config.
Parameters:
- userService: Implementation of IUserService for user business logic.
- config: API configuration, including JWT settings.
Returns:
A pointer to UserController.
func (*UserController) GetRoute ¶
func (c *UserController) GetRoute() string
GetRoute returns the base route for UserController, used for defining the primary API route.
func (*UserController) InitRoute ¶
func (c *UserController) InitRoute(route *gin.RouterGroup) *gin.RouterGroup
InitRoute initializes routes for user-related endpoints, including registration, login, and profile retrieval. The profile endpoint is protected and requires JWT authentication.
Parameters:
- route: A Gin RouterGroup to which user routes will be added.
Returns:
An updated RouterGroup with initialized user routes.
type WalletController ¶
type WalletController struct {
// contains filtered or unexported fields
}
WalletController manages wallet-related operations, including depositing and withdrawing funds.
func NewWalletController ¶
func NewWalletController(config *server.APIConfig, userService interfaces.IUserService) *WalletController
NewWalletController creates a new instance of WalletController with the provided API configuration and user service.
Parameters:
- config: A pointer to the API configuration struct, including JWT settings.
- userService: Implementation of IUserService for managing user wallet operations.
Returns:
A pointer to WalletController.
func (*WalletController) GetRoute ¶
func (c *WalletController) GetRoute() string
GetRoute returns the base route path for WalletController.
func (*WalletController) InitRoute ¶
func (c *WalletController) InitRoute(route *gin.RouterGroup) *gin.RouterGroup
InitRoute initializes wallet-related routes within the provided router group, including deposit and withdraw endpoints, both protected by JWT authentication middleware.
Parameters:
- route: A Gin RouterGroup to which wallet routes will be added.
Returns:
An updated RouterGroup with initialized wallet routes.