forked from baron/baron-sso
47 lines
1.0 KiB
Go
47 lines
1.0 KiB
Go
package handler
|
|
|
|
import (
|
|
"baron-sso-backend/internal/repository"
|
|
"baron-sso-backend/internal/service"
|
|
"runtime"
|
|
"time"
|
|
|
|
"github.com/gofiber/fiber/v2"
|
|
)
|
|
|
|
type AdminHandler struct {
|
|
Keto service.KetoService
|
|
KetoOutbox repository.KetoOutboxRepository
|
|
}
|
|
|
|
func NewAdminHandler(keto service.KetoService, ketoOutbox repository.KetoOutboxRepository) *AdminHandler {
|
|
return &AdminHandler{
|
|
Keto: keto,
|
|
KetoOutbox: ketoOutbox,
|
|
}
|
|
}
|
|
|
|
func (h *AdminHandler) CheckAuth(c *fiber.Ctx) error {
|
|
return c.Status(fiber.StatusOK).JSON(fiber.Map{"status": "ok"})
|
|
}
|
|
|
|
// GetSystemStats returns runtime statistics for monitoring
|
|
func (h *AdminHandler) GetSystemStats(c *fiber.Ctx) error {
|
|
var m runtime.MemStats
|
|
runtime.ReadMemStats(&m)
|
|
|
|
stats := fiber.Map{
|
|
"goroutines": runtime.NumGoroutine(),
|
|
"cpus": runtime.NumCPU(),
|
|
"memory": fiber.Map{
|
|
"alloc": m.Alloc,
|
|
"totalAlign": m.TotalAlloc,
|
|
"sys": m.Sys,
|
|
"numGC": m.NumGC,
|
|
},
|
|
"timestamp": time.Now(),
|
|
}
|
|
|
|
return c.Status(fiber.StatusOK).JSON(stats)
|
|
}
|