experiment: successfully implemented dependency injections for controllers and services

This commit is contained in:
2025-06-20 16:14:55 +03:00
parent 654c1eb7b5
commit aab55a143f
10 changed files with 208 additions and 156 deletions

View File

@@ -6,10 +6,18 @@ import (
"github.com/gin-gonic/gin"
)
type HealthStatus struct {
Healthy bool `json:"healthy"`
type ServiceController interface {
HealthCheck(c *gin.Context)
Router
}
type serviceControllerImpl struct{}
func NewServiceController() ServiceController {
return &serviceControllerImpl{}
}
// HealthCheck implements ServiceController.
// @Summary Get health status
// @Description Used internally for checking service health
// @Tags Service
@@ -17,6 +25,15 @@ type HealthStatus struct {
// @Produce json
// @Success 200 {object} HealthStatus "Says whether it's healthy or not"
// @Router /service/health [get]
func HealthCheck(c *gin.Context) {
func (s *serviceControllerImpl) HealthCheck(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"healthy": true})
}
// RegisterRoutes implements ServiceController.
func (s *serviceControllerImpl) RegisterRoutes(group *gin.RouterGroup) {
group.GET("/health", s.HealthCheck)
}
type HealthStatus struct {
Healthy bool `json:"healthy"`
}