25 lines
659 B
Go
25 lines
659 B
Go
package healthcheck
|
|
|
|
import (
|
|
"api-service/internal/database"
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// HealthCheckHandler handles health check requests
|
|
type HealthCheckHandler struct {
|
|
dbService database.Service
|
|
}
|
|
|
|
// NewHealthCheckHandler creates a new HealthCheckHandler
|
|
func NewHealthCheckHandler(dbService database.Service) *HealthCheckHandler {
|
|
return &HealthCheckHandler{dbService: dbService}
|
|
}
|
|
|
|
// CheckHealth checks the health of the application
|
|
func (h *HealthCheckHandler) CheckHealth(c *gin.Context) {
|
|
healthStatus := h.dbService.Health() // Call the health check function from the database service
|
|
c.JSON(http.StatusOK, healthStatus)
|
|
}
|