package handler import ( "context" "encoding/json" "fmt" "net/http" "time" "github.com/shankar0123/certctl/internal/api/middleware" ) // MetricsService defines the service interface for metrics collection. type MetricsService interface { GetDashboardSummary(ctx context.Context) (interface{}, error) } // CounterSnapshotter is the minimum surface MetricsHandler consumes // from a counter table for the Prometheus exposer. The OCSPCounters // type in internal/service satisfies this; future per-area counter // tabs (CRL, cert-export, EST, SCEP, Intune) plug in the same way. // // Production hardening II Phase 8. type CounterSnapshotter interface { Snapshot() map[string]uint64 } // MetricsHandler handles HTTP requests for metrics. // Supports both JSON format (GET /api/v1/metrics) and Prometheus exposition format // (GET /api/v1/metrics/prometheus) for integration with Prometheus, Grafana, Datadog, etc. type MetricsHandler struct { svc MetricsService serverStarted time.Time // Production hardening II Phase 8 — per-area counter snapshotters. // nil values omit the corresponding metric block; cmd/server/main.go // wires the instances at startup. The naming convention is // certctl__