2fas-server/internal/api/health/service/service.go

40 lines
1.2 KiB
Go
Raw Normal View History

2022-12-31 10:22:38 +01:00
package service
import (
"github.com/gin-gonic/gin"
2024-01-02 09:48:34 +01:00
"github.com/redis/go-redis/v9"
2023-01-30 19:59:42 +01:00
"github.com/twofas/2fas-server/config"
"github.com/twofas/2fas-server/internal/api/health/ports"
2022-12-31 10:22:38 +01:00
)
type HealthModule struct {
RoutesHandler *ports.RoutesHandler
Config config.Configuration
}
func NewHealthModule(applicationName string, config config.Configuration, redis *redis.Client) *HealthModule {
routesHandler := ports.NewRoutesHandler(applicationName, redis)
2022-12-31 10:22:38 +01:00
return &HealthModule{
RoutesHandler: routesHandler,
Config: config,
}
}
func (m *HealthModule) RegisterPublicRoutes(router *gin.Engine) {
2022-12-31 10:22:38 +01:00
router.GET("/health", m.RoutesHandler.CheckApplicationHealth)
}
func (m *HealthModule) RegisterHealth(router *gin.Engine) {
router.GET("/health", m.RoutesHandler.CheckApplicationHealth)
}
func (m *HealthModule) RegisterAdminRoutes(g *gin.RouterGroup) {
g.GET("/health", m.RoutesHandler.CheckApplicationHealth)
g.GET("/system/redis/info", m.RoutesHandler.RedisInfo)
g.GET("/system/info", m.RoutesHandler.GetApplicationConfiguration)
g.GET("/system/fake_error", m.RoutesHandler.FakeError)
g.GET("/system/fake_warning", m.RoutesHandler.FakeWarning)
g.GET("/system/fake_security_warning", m.RoutesHandler.FakeSecurityWarning)
}